cmake: Fix source-specific compile definitions
authorManuel Nickschas <sputnick@quassel-irc.org>
Mon, 13 Aug 2018 21:50:24 +0000 (23:50 +0200)
committerManuel Nickschas <sputnick@quassel-irc.org>
Sun, 18 Nov 2018 10:06:43 +0000 (11:06 +0100)
set_source_files_properties() overwrites previously specified
properties and does not have a way to append, which is bad when
e.g. conditionally adding multiple compile definitions to a file.
In this particular case, for main.cpp -DHAVE_UMASK would overwrite
-DEMBED_DATA, and thus resources would not be loaded.

Use set_property(SOURCE... APPEND PROPERTY...) instead.

src/core/CMakeLists.txt
src/main/CMakeLists.txt

index e571708..ef0f7c0 100644 (file)
@@ -52,13 +52,13 @@ if (HAVE_SSL)
 endif()
 
 if (HAVE_UMASK)
-    set_source_files_properties(oidentdconfiggenerator.cpp PROPERTIES COMPILE_DEFINITIONS HAVE_UMASK)
+    set_property(SOURCE oidentdconfiggenerator.cpp APPEND PROPERTY COMPILE_DEFINITIONS HAVE_UMASK)
 endif()
 
 if (Ldap_FOUND)
     target_sources(${TARGET} PRIVATE ldapauthenticator.cpp)
     target_link_libraries(${TARGET} PRIVATE Ldap::Ldap)
-    set_source_files_properties(core.cpp PROPERTIES COMPILE_DEFINITIONS HAVE_LDAP)
+    set_property(SOURCE core.cpp APPEND PROPERTY COMPILE_DEFINITIONS HAVE_LDAP)
 endif()
 
 if (Qca-qt5_FOUND)
index df3d765..0367467 100644 (file)
@@ -10,11 +10,11 @@ endfunction()
 
 # We need to initialize the appropriate resources, so let's give our main.cpp some hints
 if (EMBED_DATA)
-    set_source_files_properties(main.cpp PROPERTIES COMPILE_DEFINITIONS EMBED_DATA)
+    set_property(SOURCE main.cpp APPEND PROPERTY COMPILE_DEFINITIONS EMBED_DATA)
 endif()
 
 if (HAVE_UMASK)
-    set_source_files_properties(main.cpp PROPERTIES COMPILE_DEFINITIONS HAVE_UMASK)
+    set_property(SOURCE main.cpp APPEND PROPERTY COMPILE_DEFINITIONS HAVE_UMASK)
 endif()
 
 if (WITH_BUNDLED_ICONS)