From 2697e66e31a41b2e844fd78bb79fe3f45810febe Mon Sep 17 00:00:00 2001 From: jkriege2 Date: Mon, 18 Apr 2022 14:19:35 +0200 Subject: [PATCH] CMakeLists.txt: using target_sources() and making CPP-files private! --- lib/jkqtcommon/CMakeLists.txt | 6 ++++-- lib/jkqtfastplotter/CMakeLists.txt | 4 +++- lib/jkqtmathtext/CMakeLists.txt | 6 ++++-- lib/jkqtplotter/CMakeLists.txt | 6 ++++-- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/lib/jkqtcommon/CMakeLists.txt b/lib/jkqtcommon/CMakeLists.txt index acf7b15b2e..4f39404f15 100644 --- a/lib/jkqtcommon/CMakeLists.txt +++ b/lib/jkqtcommon/CMakeLists.txt @@ -72,7 +72,8 @@ include(CMakePackageConfigHelpers) if(JKQtPlotter_BUILD_SHARED_LIBS) - add_library(${libsh_name} SHARED ${SOURCES} ${HEADERS}) + add_library(${libsh_name} SHARED ) + target_sources(${libsh_name} PRIVATE ${SOURCES} PUBLIC ${HEADERS}) set_property(TARGET ${libsh_name} PROPERTY VERSION "${PROJECT_VERSION}") set_property(TARGET ${libsh_name} PROPERTY OUTPUT_NAME "${libsh_name_decorated}") target_link_libraries(${libsh_name} PUBLIC Qt5::Core Qt5::Gui Qt5::Xml Qt5::Widgets Qt5::PrintSupport) @@ -100,7 +101,8 @@ if(JKQtPlotter_BUILD_SHARED_LIBS) endif() if(JKQtPlotter_BUILD_STATIC_LIBS) - add_library(${lib_name} STATIC ${SOURCES} ${HEADERS}) + add_library(${lib_name} STATIC ) + target_sources(${lib_name} PRIVATE ${SOURCES} PUBLIC ${HEADERS}) set_property(TARGET ${lib_name} PROPERTY VERSION "${PROJECT_VERSION}") set_property(TARGET ${lib_name} PROPERTY OUTPUT_NAME "${lib_name_decorated}") set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD 11) diff --git a/lib/jkqtfastplotter/CMakeLists.txt b/lib/jkqtfastplotter/CMakeLists.txt index a7f8c6aeaf..287b923436 100644 --- a/lib/jkqtfastplotter/CMakeLists.txt +++ b/lib/jkqtfastplotter/CMakeLists.txt @@ -34,7 +34,8 @@ include(CMakePackageConfigHelpers) if(JKQtPlotter_BUILD_SHARED_LIBS) - add_library(${libsh_name} SHARED ${SOURCES} ${HEADERS} ${RESOURCES}) + add_library(${libsh_name} SHARED ) + target_sources(${libsh_name} PRIVATE ${SOURCES} ${RESOURCES} PUBLIC ${HEADERS}) set_property(TARGET ${libsh_name} PROPERTY VERSION "${PROJECT_VERSION}") set_property(TARGET ${libsh_name} PROPERTY OUTPUT_NAME "${libsh_name_decorated}") target_link_libraries(${libsh_name} PUBLIC Qt5::Core Qt5::Gui Qt5::Widgets Qt5::PrintSupport Qt5::OpenGL JKQTCommonSharedLib) @@ -63,6 +64,7 @@ endif() if(JKQtPlotter_BUILD_STATIC_LIBS) add_library(${lib_name} STATIC ${SOURCES} ${HEADERS} ${RESOURCES}) + target_sources(${lib_name} PRIVATE ${SOURCES} ${RESOURCES} PUBLIC ${HEADERS}) set_property(TARGET ${lib_name} PROPERTY VERSION "${PROJECT_VERSION}") set_property(TARGET ${lib_name} PROPERTY OUTPUT_NAME "${lib_name_decorated}") set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD 11) diff --git a/lib/jkqtmathtext/CMakeLists.txt b/lib/jkqtmathtext/CMakeLists.txt index 7bfec50492..dcc86fcb16 100644 --- a/lib/jkqtmathtext/CMakeLists.txt +++ b/lib/jkqtmathtext/CMakeLists.txt @@ -39,7 +39,8 @@ endif(JKQtPlotter_BUILD_INCLUDE_XITS_FONTS) include(CMakePackageConfigHelpers) if(JKQtPlotter_BUILD_SHARED_LIBS) - add_library(${libsh_name} SHARED ${SOURCES} ${HEADERS} ${RESOURCES}) + add_library(${libsh_name} SHARED + target_sources(${libsh_name} PRIVATE ${SOURCES} ${RESOURCES} PUBLIC ${HEADERS}) set_property(TARGET ${libsh_name} PROPERTY VERSION "${PROJECT_VERSION}") set_property(TARGET ${libsh_name} PROPERTY OUTPUT_NAME "${libsh_name_decorated}") target_link_libraries(${libsh_name} PUBLIC Qt5::Core Qt5::Gui Qt5::Widgets Qt5::PrintSupport JKQTCommonSharedLib) @@ -70,7 +71,8 @@ if(JKQtPlotter_BUILD_SHARED_LIBS) endif() if(JKQtPlotter_BUILD_STATIC_LIBS) - add_library(${lib_name} STATIC ${SOURCES} ${HEADERS} ${RESOURCES}) + add_library(${lib_name} STATIC ) + target_sources(${lib_name} PRIVATE ${SOURCES} ${RESOURCES} PUBLIC ${HEADERS}) set_property(TARGET ${lib_name} PROPERTY VERSION "${PROJECT_VERSION}") set_property(TARGET ${lib_name} PROPERTY OUTPUT_NAME "${lib_name_decorated}") set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD 11) diff --git a/lib/jkqtplotter/CMakeLists.txt b/lib/jkqtplotter/CMakeLists.txt index d4ffc1676b..a093dd4697 100644 --- a/lib/jkqtplotter/CMakeLists.txt +++ b/lib/jkqtplotter/CMakeLists.txt @@ -141,7 +141,8 @@ include(CMakePackageConfigHelpers) if(JKQtPlotter_BUILD_SHARED_LIBS) - add_library(${libsh_name} SHARED ${SOURCES} ${SOURCES_GRAPHS} ${SOURCES_GUI} ${HEADERS} ${HEADERS_GRAPHS} ${HEADERS_GUI} ${RESOURCES}) + add_library(${libsh_name} SHARED ) + target_sources(${libsh_name} PRIVATE ${SOURCES} ${SOURCES_GRAPHS} ${SOURCES_GUI} ${RESOURCES} PUBLIC ${HEADERS} ${HEADERS_GRAPHS} ${HEADERS_GUI}) set_property(TARGET ${libsh_name} PROPERTY VERSION "${PROJECT_VERSION}") set_property(TARGET ${libsh_name} PROPERTY OUTPUT_NAME "${libsh_name_decorated}") target_link_libraries(${libsh_name} PUBLIC Qt5::Core Qt5::Gui Qt5::Widgets Qt5::PrintSupport Qt5::Svg Qt5::Xml JKQTCommonSharedLib JKQTMathTextSharedLib) @@ -169,7 +170,8 @@ if(JKQtPlotter_BUILD_SHARED_LIBS) endif() if(JKQtPlotter_BUILD_STATIC_LIBS) - add_library(${lib_name} STATIC ${SOURCES} ${SOURCES_GRAPHS} ${SOURCES_GUI} ${HEADERS} ${HEADERS_GRAPHS} ${HEADERS_GUI} ${RESOURCES}) + add_library(${lib_name} STATIC ) + target_sources(${libsh_name} PRIVATE ${SOURCES} ${SOURCES_GRAPHS} ${SOURCES_GUI} ${RESOURCES} PUBLIC ${HEADERS} ${HEADERS_GRAPHS} ${HEADERS_GUI}) set_property(TARGET ${lib_name} PROPERTY VERSION "${PROJECT_VERSION}") set_property(TARGET ${lib_name} PROPERTY OUTPUT_NAME "${lib_name_decorated}") set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD 11)