]> git.ipfire.org Git - thirdparty/xz.git/commitdiff
CMake: Specify LINKER_LANGUAGE for libgnu target to fix Ninja Generator.
authorJia Tan <jiat0218@gmail.com>
Fri, 29 Sep 2023 11:58:44 +0000 (19:58 +0800)
committerJia Tan <jiat0218@gmail.com>
Fri, 29 Sep 2023 11:58:44 +0000 (19:58 +0800)
CMake is unable to guess the linker language for just a header file so
it must be explicitly set.

CMakeLists.txt

index ffb381b4be3c42ccefa3feb4d0a52e64ead432d0..3e536a87feb369987fa42da589f9dfef3b17a232 100644 (file)
@@ -1008,6 +1008,12 @@ add_library(libgnu OBJECT)
 # file. So we give it a header file that results in no output files.
 target_sources(libgnu PRIVATE lib/getopt.in.h)
 
+# The Ninja Generator requires setting the linker language since it cannot
+# guess the programming language of just a header file. Setting this
+# property avoids needing an empty .c file or an non-empty unnecessary .c
+# file.
+set_target_properties(libgnu PROPERTIES LINKER_LANGUAGE C)
+
 # Create /lib directory in the build directory and add it to the include path.
 file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/lib")
 target_include_directories(libgnu PUBLIC "${CMAKE_CURRENT_BINARY_DIR}/lib")