improvements in CMake setup:

- removed more global settings (these are now target-specific)
- exporting now Config.cmake, which contains find_package(Qt) and loads a separate Targets.cmake
This commit is contained in:
jkriege2 2020-06-28 15:53:26 +02:00
parent 5f1579314e
commit 52d3349199
11 changed files with 311 additions and 133 deletions

View File

@ -1,7 +1,16 @@
cmake_minimum_required(VERSION 3.0) cmake_minimum_required(VERSION 3.0)
# Project Name and Version # Project Name and Version
project(JKQTPlotter LANGUAGES CXX VERSION 2020.01.1) # starting from 2020: using semantic version number <major>.<minor>.<patch>
# - bugfixes which do not change the API/ABI lead to an increase in <patch>
# - backward-compatible API/ABI-changes mean an increasing <minor> version
# - NON backward-compatible API/ABI-changes mean an increasing <major> version
# relation to older versioning scheme:
# - v2015.10 <--> 1.0.0
# - v2018.08 <--> 2.0.0
# - v2019.11 <--> 3.x.y
# ==> sematic versioning starts with 4.0.0
project(JKQTPlotter LANGUAGES CXX VERSION 4.0.0)
# set search path for CMake files # set search path for CMake files

View File

@ -4,18 +4,6 @@ cmake_minimum_required(VERSION 3.1)
set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED on) set(CMAKE_CXX_STANDARD_REQUIRED on)
if(MINGW)
# COMPILER-SETTINGS FOR MINGW
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions")
elseif(MSVC)
# COMPILER-SETTINGS FOR MS VISUAL C++
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc")
# To fix error: C2338: va_start argument must not
# have reference type and must not be parenthesized
add_definitions(/D_CRT_NO_VA_START_VALIDATION)
add_definitions(/DNOMINMAX)
endif()
if(NOT APPLE) if(NOT APPLE)
set(CMAKE_INSTALL_RPATH $ORIGIN) set(CMAKE_INSTALL_RPATH $ORIGIN)
endif() endif()

View File

@ -16,8 +16,6 @@ set(CMAKE_CXX_STANDARD 11)
find_package(Qt5 COMPONENTS Core Gui Widgets PrintSupport Svg Xml OpenGl REQUIRED) find_package(Qt5 COMPONENTS Core Gui Widgets PrintSupport Svg Xml OpenGl REQUIRED)
# include JKQTPlotter # include JKQTPlotter
find_package(JKQTCommonLib REQUIRED)
find_package(JKQTMathTextLib REQUIRED)
find_package(JKQTPlotterLib REQUIRED) find_package(JKQTPlotterLib REQUIRED)
# For Visual Studio, we need to set some additional compiler options # For Visual Studio, we need to set some additional compiler options

View File

@ -71,12 +71,22 @@ include(CMakePackageConfigHelpers)
if(JKQtPlotter_BUILD_SHARED_LIBS) if(JKQtPlotter_BUILD_SHARED_LIBS)
add_library(${libsh_name} SHARED ${SOURCES} ${HEADERS}) add_library(${libsh_name} SHARED ${SOURCES} ${HEADERS})
target_compile_features(${libsh_name} PUBLIC cxx_std_11)
set_property(TARGET ${libsh_name} PROPERTY VERSION "${PROJECT_VERSION}") set_property(TARGET ${libsh_name} PROPERTY VERSION "${PROJECT_VERSION}")
set_property(TARGET ${libsh_name} PROPERTY OUTPUT_NAME "${libsh_name_decorated}") 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) target_link_libraries(${libsh_name} PUBLIC Qt5::Core Qt5::Gui Qt5::Xml Qt5::Widgets Qt5::PrintSupport)
target_compile_definitions(${libsh_name} PUBLIC JKQTCOMMON_LIB_IN_DLL) target_compile_definitions(${libsh_name} PUBLIC JKQTCOMMON_LIB_IN_DLL)
target_compile_definitions(${libsh_name} PRIVATE JKQTCOMMON_LIB_EXPORT_LIBRARY) target_compile_definitions(${libsh_name} PRIVATE JKQTCOMMON_LIB_EXPORT_LIBRARY)
set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD 11)
set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD_REQUIRED TRUE)
target_compile_features(${libsh_name} PUBLIC cxx_std_11)
if(MINGW)
# COMPILER-SETTINGS FOR MINGW
target_compile_options(${libsh_name} PUBLIC -fexceptions)
elseif(MSVC)
# COMPILER-SETTINGS FOR MS VISUAL C++
target_compile_options(${libsh_name} PUBLIC /EHsc)
target_compile_definitions(${libsh_name} PUBLIC /DNOMINMAX)
endif()
target_include_directories(${libsh_name} PUBLIC target_include_directories(${libsh_name} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
@ -89,9 +99,19 @@ endif()
if(JKQtPlotter_BUILD_STATIC_LIBS) if(JKQtPlotter_BUILD_STATIC_LIBS)
add_library(${lib_name} STATIC ${SOURCES} ${HEADERS}) add_library(${lib_name} STATIC ${SOURCES} ${HEADERS})
target_compile_features(${lib_name} PUBLIC cxx_std_11)
set_property(TARGET ${lib_name} PROPERTY VERSION "${PROJECT_VERSION}") 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 OUTPUT_NAME "${lib_name_decorated}")
set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD 11)
set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD_REQUIRED TRUE)
target_compile_features(${lib_name} PUBLIC cxx_std_11)
if(MINGW)
# COMPILER-SETTINGS FOR MINGW
target_compile_options(${lib_name} PUBLIC -fexceptions)
elseif(MSVC)
# COMPILER-SETTINGS FOR MS VISUAL C++
target_compile_options(${lib_name} PUBLIC /EHsc)
target_compile_definitions(${lib_name} PUBLIC /DNOMINMAX)
endif()
target_include_directories(${lib_name} PUBLIC target_include_directories(${lib_name} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
@ -112,12 +132,18 @@ if(JKQtPlotter_BUILD_SHARED_LIBS)
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${libIncludeSubdir} INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${libIncludeSubdir}
) )
set(JKQTP_CURRENT_TARGET_FILENAME "${libsh_name}Targets.cmake")
configure_file(LibTarget.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/${libsh_name}Config.cmake" @ONLY)
install(EXPORT ${libsh_name}_TARGETS install(EXPORT ${libsh_name}_TARGETS
FILE ${libsh_name}Config.cmake FILE "${JKQTP_CURRENT_TARGET_FILENAME}"
DESTINATION lib/cmake/${libsh_name} DESTINATION lib/cmake
) )
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${libsh_name}Version.cmake" install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${libsh_name}Version.cmake"
DESTINATION lib/cmake/${libsh_name} ) DESTINATION lib/cmake )
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${libsh_name}Config.cmake"
DESTINATION lib/cmake )
endif(JKQtPlotter_BUILD_SHARED_LIBS) endif(JKQtPlotter_BUILD_SHARED_LIBS)
if(JKQtPlotter_BUILD_STATIC_LIBS) if(JKQtPlotter_BUILD_STATIC_LIBS)
@ -127,12 +153,18 @@ if(JKQtPlotter_BUILD_SHARED_LIBS)
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${libIncludeSubdir} INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${libIncludeSubdir}
) )
set(JKQTP_CURRENT_TARGET_FILENAME "${lib_name}Targets.cmake")
configure_file(LibTarget.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/${lib_name}Config.cmake" @ONLY)
install(EXPORT ${lib_name}_TARGETS install(EXPORT ${lib_name}_TARGETS
FILE ${lib_name}Config.cmake FILE "${JKQTP_CURRENT_TARGET_FILENAME}"
DESTINATION lib/cmake/${lib_name} DESTINATION lib/cmake
) )
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${lib_name}Version.cmake" install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${lib_name}Version.cmake"
DESTINATION lib/cmake/${lib_name} ) DESTINATION lib/cmake )
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${lib_name}Config.cmake"
DESTINATION lib/cmake )
endif(JKQtPlotter_BUILD_STATIC_LIBS) endif(JKQtPlotter_BUILD_STATIC_LIBS)
install(FILES ${HEADERS} install(FILES ${HEADERS}

View File

@ -0,0 +1,13 @@
# Package-config file for @libBasename@ library
# (part of JKQtPlotter, version @PROJECT_VERSION@)
#
# see: https://github.com/jkriege2/JKQtPlotter
# Copyright: (c) Jan Krieger <jan@jkrieger.de>
#
# package requires Qt 5
find_package(Qt5 5.0 REQUIRED Core Gui Widgets PrintSupport Svg Xml OpenGL)
# include auto-generated targets.cmake file
include("${CMAKE_CURRENT_LIST_DIR}/@JKQTP_CURRENT_TARGET_FILENAME@")

View File

@ -35,11 +35,21 @@ include(CMakePackageConfigHelpers)
if(JKQtPlotter_BUILD_SHARED_LIBS) if(JKQtPlotter_BUILD_SHARED_LIBS)
add_library(${libsh_name} SHARED ${SOURCES} ${HEADERS} ${RESOURCES}) add_library(${libsh_name} SHARED ${SOURCES} ${HEADERS} ${RESOURCES})
target_compile_features(${libsh_name} PUBLIC cxx_std_11)
set_property(TARGET ${libsh_name} PROPERTY VERSION "${PROJECT_VERSION}") set_property(TARGET ${libsh_name} PROPERTY VERSION "${PROJECT_VERSION}")
set_property(TARGET ${libsh_name} PROPERTY OUTPUT_NAME "${libsh_name_decorated}") 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) target_link_libraries(${libsh_name} PUBLIC Qt5::Core Qt5::Gui Qt5::Widgets Qt5::PrintSupport Qt5::OpenGL JKQTCommonSharedLib)
target_compile_definitions(${libsh_name} PUBLIC JKQTFASTPLOTTER_LIB_IN_DLL) target_compile_definitions(${libsh_name} PUBLIC JKQTFASTPLOTTER_LIB_IN_DLL)
set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD 11)
set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD_REQUIRED TRUE)
target_compile_features(${libsh_name} PUBLIC cxx_std_11)
if(MINGW)
# COMPILER-SETTINGS FOR MINGW
target_compile_options(${libsh_name} PUBLIC -fexceptions)
elseif(MSVC)
# COMPILER-SETTINGS FOR MS VISUAL C++
target_compile_options(${libsh_name} PUBLIC /EHsc)
target_compile_definitions(${libsh_name} PUBLIC /DNOMINMAX)
endif()
target_compile_definitions(${libsh_name} PRIVATE JKQTFASTPLOTTER_LIB_EXPORT_LIBRARY) target_compile_definitions(${libsh_name} PRIVATE JKQTFASTPLOTTER_LIB_EXPORT_LIBRARY)
target_include_directories(${libsh_name} PUBLIC target_include_directories(${libsh_name} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../>
@ -53,9 +63,19 @@ endif()
if(JKQtPlotter_BUILD_STATIC_LIBS) if(JKQtPlotter_BUILD_STATIC_LIBS)
add_library(${lib_name} STATIC ${SOURCES} ${HEADERS} ${RESOURCES}) add_library(${lib_name} STATIC ${SOURCES} ${HEADERS} ${RESOURCES})
target_compile_features(${lib_name} PUBLIC cxx_std_11)
set_property(TARGET ${lib_name} PROPERTY VERSION "${PROJECT_VERSION}") 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 OUTPUT_NAME "${lib_name_decorated}")
set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD 11)
set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD_REQUIRED TRUE)
if(MINGW)
# COMPILER-SETTINGS FOR MINGW
target_compile_options(${lib_name} PUBLIC -fexceptions)
elseif(MSVC)
# COMPILER-SETTINGS FOR MS VISUAL C++
target_compile_options(${lib_name} PUBLIC /EHsc)
target_compile_definitions(${lib_name} PUBLIC /DNOMINMAX)
endif()
target_compile_features(${lib_name} PUBLIC cxx_std_11)
target_link_libraries(${lib_name} PUBLIC Qt5::Core Qt5::Gui Qt5::Widgets Qt5::PrintSupport Qt5::OpenGL JKQTCommonLib) target_link_libraries(${lib_name} PUBLIC Qt5::Core Qt5::Gui Qt5::Widgets Qt5::PrintSupport Qt5::OpenGL JKQTCommonLib)
target_include_directories(${lib_name} PUBLIC target_include_directories(${lib_name} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../>
@ -76,12 +96,18 @@ if(JKQtPlotter_BUILD_SHARED_LIBS)
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${libIncludeSubdir} INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${libIncludeSubdir}
) )
set(JKQTP_CURRENT_TARGET_FILENAME "${libsh_name}Targets.cmake")
set(JKQTP_CURRENT_TARGET_SHAREDPART "Shared")
configure_file(LibTarget.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/${libsh_name}Config.cmake" @ONLY)
install(EXPORT ${libsh_name}_TARGETS install(EXPORT ${libsh_name}_TARGETS
FILE ${libsh_name}Config.cmake FILE "${JKQTP_CURRENT_TARGET_FILENAME}"
DESTINATION lib/cmake/${libsh_name} DESTINATION lib/cmake
) )
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${libsh_name}Version.cmake" install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${libsh_name}Version.cmake"
DESTINATION lib/cmake/${libsh_name} ) DESTINATION lib/cmake )
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${libsh_name}Config.cmake"
DESTINATION lib/cmake )
endif(JKQtPlotter_BUILD_SHARED_LIBS) endif(JKQtPlotter_BUILD_SHARED_LIBS)
if(JKQtPlotter_BUILD_STATIC_LIBS) if(JKQtPlotter_BUILD_STATIC_LIBS)
@ -91,12 +117,18 @@ if(JKQtPlotter_BUILD_STATIC_LIBS)
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${libIncludeSubdir} INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${libIncludeSubdir}
) )
set(JKQTP_CURRENT_TARGET_FILENAME "${lib_name}Targets.cmake")
set(JKQTP_CURRENT_TARGET_SHAREDPART "")
configure_file(LibTarget.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/${lib_name}Config.cmake" @ONLY)
install(EXPORT ${lib_name}_TARGETS install(EXPORT ${lib_name}_TARGETS
FILE ${lib_name}Config.cmake FILE "${JKQTP_CURRENT_TARGET_FILENAME}"
DESTINATION lib/cmake/${lib_name} DESTINATION lib/cmake
) )
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${lib_name}Version.cmake" install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${lib_name}Version.cmake"
DESTINATION lib/cmake/${lib_name} ) DESTINATION lib/cmake )
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${lib_name}Config.cmake"
DESTINATION lib/cmake )
endif(JKQtPlotter_BUILD_STATIC_LIBS) endif(JKQtPlotter_BUILD_STATIC_LIBS)
install(FILES ${HEADERS} install(FILES ${HEADERS}

View File

@ -0,0 +1,14 @@
# Package-config file for @libBasename@ library
# (part of JKQtPlotter, version @PROJECT_VERSION@)
#
# see: https://github.com/jkriege2/JKQtPlotter
# Copyright: (c) Jan Krieger <jan@jkrieger.de>
#
# package requires Qt 5
find_package(Qt5 5.0 REQUIRED Core Gui Widgets PrintSupport Svg Xml OpenGL)
find_package(JKQTCommon@JKQTP_CURRENT_TARGET_SHAREDPART@Lib REQUIRED PATHS ${CMAKE_CURRENT_LIST_DIR} ${CMAKE_MODULE_PATH})
# include auto-generated targets.cmake file
include("${CMAKE_CURRENT_LIST_DIR}/@JKQTP_CURRENT_TARGET_FILENAME@")

View File

@ -40,12 +40,22 @@ include(CMakePackageConfigHelpers)
if(JKQtPlotter_BUILD_SHARED_LIBS) if(JKQtPlotter_BUILD_SHARED_LIBS)
add_library(${libsh_name} SHARED ${SOURCES} ${HEADERS} ${RESOURCES}) add_library(${libsh_name} SHARED ${SOURCES} ${HEADERS} ${RESOURCES})
target_compile_features(${libsh_name} PUBLIC cxx_std_11)
set_property(TARGET ${libsh_name} PROPERTY VERSION "${PROJECT_VERSION}") set_property(TARGET ${libsh_name} PROPERTY VERSION "${PROJECT_VERSION}")
set_property(TARGET ${libsh_name} PROPERTY OUTPUT_NAME "${libsh_name_decorated}") 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) target_link_libraries(${libsh_name} PUBLIC Qt5::Core Qt5::Gui Qt5::Widgets Qt5::PrintSupport JKQTCommonSharedLib)
target_compile_definitions(${libsh_name} PUBLIC JKQTMATHTEXT_LIB_IN_DLL) target_compile_definitions(${libsh_name} PUBLIC JKQTMATHTEXT_LIB_IN_DLL)
target_compile_definitions(${libsh_name} PRIVATE JKQTMATHTEXT_LIB_EXPORT_LIBRARY) target_compile_definitions(${libsh_name} PRIVATE JKQTMATHTEXT_LIB_EXPORT_LIBRARY)
set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD 11)
set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD_REQUIRED TRUE)
target_compile_features(${libsh_name} PUBLIC cxx_std_11)
if(MINGW)
# COMPILER-SETTINGS FOR MINGW
target_compile_options(${libsh_name} PUBLIC -fexceptions)
elseif(MSVC)
# COMPILER-SETTINGS FOR MS VISUAL C++
target_compile_options(${libsh_name} PUBLIC /EHsc)
target_compile_definitions(${libsh_name} PUBLIC /DNOMINMAX)
endif()
target_include_directories(${libsh_name} PUBLIC target_include_directories(${libsh_name} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
@ -61,9 +71,19 @@ endif()
if(JKQtPlotter_BUILD_STATIC_LIBS) if(JKQtPlotter_BUILD_STATIC_LIBS)
add_library(${lib_name} STATIC ${SOURCES} ${HEADERS} ${RESOURCES}) add_library(${lib_name} STATIC ${SOURCES} ${HEADERS} ${RESOURCES})
target_compile_features(${lib_name} PUBLIC cxx_std_11)
set_property(TARGET ${lib_name} PROPERTY VERSION "${PROJECT_VERSION}") 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 OUTPUT_NAME "${lib_name_decorated}")
set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD 11)
set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD_REQUIRED TRUE)
target_compile_features(${lib_name} PUBLIC cxx_std_11)
if(MINGW)
# COMPILER-SETTINGS FOR MINGW
target_compile_options(${lib_name} PUBLIC -fexceptions)
elseif(MSVC)
# COMPILER-SETTINGS FOR MS VISUAL C++
target_compile_options(${lib_name} PUBLIC /EHsc)
target_compile_definitions(${lib_name} PUBLIC /DNOMINMAX)
endif()
if(JKQtPlotter_BUILD_INCLUDE_XITS_FONTS) if(JKQtPlotter_BUILD_INCLUDE_XITS_FONTS)
target_compile_definitions(${lib_name} PRIVATE JKQTMATHTEXT_COMPILED_WITH_XITS) target_compile_definitions(${lib_name} PRIVATE JKQTMATHTEXT_COMPILED_WITH_XITS)
endif(JKQtPlotter_BUILD_INCLUDE_XITS_FONTS) endif(JKQtPlotter_BUILD_INCLUDE_XITS_FONTS)
@ -87,12 +107,18 @@ if(JKQtPlotter_BUILD_SHARED_LIBS)
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${libIncludeSubdir} INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${libIncludeSubdir}
) )
set(JKQTP_CURRENT_TARGET_FILENAME "${libsh_name}Targets.cmake")
set(JKQTP_CURRENT_TARGET_SHAREDPART "Shared")
configure_file(LibTarget.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/${libsh_name}Config.cmake" @ONLY)
install(EXPORT ${libsh_name}_TARGETS install(EXPORT ${libsh_name}_TARGETS
FILE ${libsh_name}Config.cmake FILE "${JKQTP_CURRENT_TARGET_FILENAME}"
DESTINATION lib/cmake/${libsh_name} DESTINATION lib/cmake
) )
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${libsh_name}Version.cmake" install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${libsh_name}Version.cmake"
DESTINATION lib/cmake/${libsh_name} ) DESTINATION lib/cmake )
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${libsh_name}Config.cmake"
DESTINATION lib/cmake )
endif(JKQtPlotter_BUILD_SHARED_LIBS) endif(JKQtPlotter_BUILD_SHARED_LIBS)
if(JKQtPlotter_BUILD_STATIC_LIBS) if(JKQtPlotter_BUILD_STATIC_LIBS)
@ -102,12 +128,18 @@ if(JKQtPlotter_BUILD_STATIC_LIBS)
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${libIncludeSubdir} INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${libIncludeSubdir}
) )
set(JKQTP_CURRENT_TARGET_FILENAME "${lib_name}Targets.cmake")
set(JKQTP_CURRENT_TARGET_SHAREDPART "")
configure_file(LibTarget.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/${lib_name}Config.cmake" @ONLY)
install(EXPORT ${lib_name}_TARGETS install(EXPORT ${lib_name}_TARGETS
FILE ${lib_name}Config.cmake FILE "${JKQTP_CURRENT_TARGET_FILENAME}"
DESTINATION lib/cmake/${lib_name} DESTINATION lib/cmake
) )
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${lib_name}Version.cmake" install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${lib_name}Version.cmake"
DESTINATION lib/cmake/${lib_name} ) DESTINATION lib/cmake )
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${lib_name}Config.cmake"
DESTINATION lib/cmake )
endif(JKQtPlotter_BUILD_STATIC_LIBS) endif(JKQtPlotter_BUILD_STATIC_LIBS)
install(FILES ${HEADERS} install(FILES ${HEADERS}

View File

@ -0,0 +1,14 @@
# Package-config file for @libBasename@ library
# (part of JKQtPlotter, version @PROJECT_VERSION@)
#
# see: https://github.com/jkriege2/JKQtPlotter
# Copyright: (c) Jan Krieger <jan@jkrieger.de>
#
# package requires Qt 5
find_package(Qt5 5.0 REQUIRED Core Gui Widgets PrintSupport Svg Xml OpenGL)
find_package(JKQTCommon@JKQTP_CURRENT_TARGET_SHAREDPART@Lib REQUIRED PATHS ${CMAKE_CURRENT_LIST_DIR} ${CMAKE_MODULE_PATH})
# include auto-generated targets.cmake file
include("${CMAKE_CURRENT_LIST_DIR}/@JKQTP_CURRENT_TARGET_FILENAME@")

View File

@ -132,12 +132,22 @@ include(CMakePackageConfigHelpers)
if(JKQtPlotter_BUILD_SHARED_LIBS) if(JKQtPlotter_BUILD_SHARED_LIBS)
add_library(${libsh_name} SHARED ${SOURCES} ${SOURCES_GRAPHS} ${SOURCES_GUI} ${SOURCES_OVERLAYS} ${HEADERS} ${HEADERS_GRAPHS} ${HEADERS_GUI} ${HEADERS_OVERLAYS} ${RESOURCES}) add_library(${libsh_name} SHARED ${SOURCES} ${SOURCES_GRAPHS} ${SOURCES_GUI} ${SOURCES_OVERLAYS} ${HEADERS} ${HEADERS_GRAPHS} ${HEADERS_GUI} ${HEADERS_OVERLAYS} ${RESOURCES})
target_compile_features(${libsh_name} PUBLIC cxx_std_11)
set_property(TARGET ${libsh_name} PROPERTY VERSION "${PROJECT_VERSION}") set_property(TARGET ${libsh_name} PROPERTY VERSION "${PROJECT_VERSION}")
set_property(TARGET ${libsh_name} PROPERTY OUTPUT_NAME "${libsh_name_decorated}") 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) target_link_libraries(${libsh_name} PUBLIC Qt5::Core Qt5::Gui Qt5::Widgets Qt5::PrintSupport Qt5::Svg Qt5::Xml JKQTCommonSharedLib JKQTMathTextSharedLib)
set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD 11)
set_property(TARGET ${libsh_name} PROPERTY CXX_STANDARD_REQUIRED TRUE)
target_compile_features(${libsh_name} PUBLIC cxx_std_11)
target_compile_definitions(${libsh_name} PUBLIC JKQTPLOTTER_LIB_IN_DLL) target_compile_definitions(${libsh_name} PUBLIC JKQTPLOTTER_LIB_IN_DLL)
target_compile_definitions(${libsh_name} PRIVATE JKQTPLOTTER_LIB_EXPORT_LIBRARY) target_compile_definitions(${libsh_name} PRIVATE JKQTPLOTTER_LIB_EXPORT_LIBRARY)
if(MINGW)
# COMPILER-SETTINGS FOR MINGW
target_compile_options(${libsh_name} PUBLIC -fexceptions)
elseif(MSVC)
# COMPILER-SETTINGS FOR MS VISUAL C++
target_compile_options(${libsh_name} PUBLIC /EHsc)
target_compile_definitions(${libsh_name} PUBLIC /DNOMINMAX)
endif()
target_include_directories(${libsh_name} PUBLIC target_include_directories(${libsh_name} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
@ -150,9 +160,19 @@ endif()
if(JKQtPlotter_BUILD_STATIC_LIBS) if(JKQtPlotter_BUILD_STATIC_LIBS)
add_library(${lib_name} STATIC ${SOURCES} ${SOURCES_GRAPHS} ${SOURCES_GUI} ${SOURCES_OVERLAYS} ${HEADERS} ${HEADERS_GRAPHS} ${HEADERS_GUI} ${HEADERS_OVERLAYS} ${RESOURCES}) add_library(${lib_name} STATIC ${SOURCES} ${SOURCES_GRAPHS} ${SOURCES_GUI} ${SOURCES_OVERLAYS} ${HEADERS} ${HEADERS_GRAPHS} ${HEADERS_GUI} ${HEADERS_OVERLAYS} ${RESOURCES})
target_compile_features(${lib_name} PUBLIC cxx_std_11)
set_property(TARGET ${lib_name} PROPERTY VERSION "${PROJECT_VERSION}") 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 OUTPUT_NAME "${lib_name_decorated}")
set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD 11)
set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD_REQUIRED TRUE)
if(MINGW)
# COMPILER-SETTINGS FOR MINGW
target_compile_options(${lib_name} PUBLIC -fexceptions)
elseif(MSVC)
# COMPILER-SETTINGS FOR MS VISUAL C++
target_compile_options(${lib_name} PUBLIC /EHsc)
target_compile_definitions(${lib_name} PUBLIC /DNOMINMAX)
endif()
target_compile_features(${lib_name} PUBLIC cxx_std_11)
target_include_directories(${lib_name} PUBLIC target_include_directories(${lib_name} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
@ -173,12 +193,18 @@ if(JKQtPlotter_BUILD_SHARED_LIBS)
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
) )
set(JKQTP_CURRENT_TARGET_FILENAME "${libsh_name}Targets.cmake")
set(JKQTP_CURRENT_TARGET_SHAREDPART "Shared")
configure_file(LibTarget.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/${libsh_name}Config.cmake" @ONLY)
install(EXPORT ${libsh_name}_TARGETS install(EXPORT ${libsh_name}_TARGETS
FILE ${libsh_name}Config.cmake FILE "${JKQTP_CURRENT_TARGET_FILENAME}"
DESTINATION lib/cmake/${libsh_name} DESTINATION lib/cmake
) )
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${libsh_name}Version.cmake" install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${libsh_name}Version.cmake"
DESTINATION lib/cmake/${libsh_name} ) DESTINATION lib/cmake )
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${libsh_name}Config.cmake"
DESTINATION lib/cmake )
endif(JKQtPlotter_BUILD_SHARED_LIBS) endif(JKQtPlotter_BUILD_SHARED_LIBS)
if(JKQtPlotter_BUILD_STATIC_LIBS) if(JKQtPlotter_BUILD_STATIC_LIBS)
@ -188,12 +214,18 @@ if(JKQtPlotter_BUILD_STATIC_LIBS)
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
) )
set(JKQTP_CURRENT_TARGET_FILENAME "${lib_name}Targets.cmake")
set(JKQTP_CURRENT_TARGET_SHAREDPART "")
configure_file(LibTarget.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/${lib_name}Config.cmake" @ONLY)
install(EXPORT ${lib_name}_TARGETS install(EXPORT ${lib_name}_TARGETS
FILE ${lib_name}Config.cmake FILE "${JKQTP_CURRENT_TARGET_FILENAME}"
DESTINATION lib/cmake/${lib_name} DESTINATION lib/cmake
) )
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${lib_name}Version.cmake" install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${lib_name}Version.cmake"
DESTINATION lib/cmake/${lib_name} ) DESTINATION lib/cmake )
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${lib_name}Config.cmake"
DESTINATION lib/cmake )
endif(JKQtPlotter_BUILD_STATIC_LIBS) endif(JKQtPlotter_BUILD_STATIC_LIBS)
install(FILES ${HEADERS} install(FILES ${HEADERS}

View File

@ -0,0 +1,14 @@
# Package-config file for @libBasename@ library
# (part of JKQtPlotter, version @PROJECT_VERSION@)
#
# see: https://github.com/jkriege2/JKQtPlotter
# Copyright: (c) Jan Krieger <jan@jkrieger.de>
#
# package requires Qt 5
find_package(Qt5 5.0 REQUIRED Core Gui Widgets PrintSupport Svg Xml OpenGL)
find_package(JKQTCommon@JKQTP_CURRENT_TARGET_SHAREDPART@Lib REQUIRED PATHS ${CMAKE_CURRENT_LIST_DIR} ${CMAKE_MODULE_PATH})
find_package(JKQTMathText@JKQTP_CURRENT_TARGET_SHAREDPART@Lib REQUIRED PATHS ${CMAKE_CURRENT_LIST_DIR} ${CMAKE_MODULE_PATH})
# include auto-generated targets.cmake file
include("${CMAKE_CURRENT_LIST_DIR}/@JKQTP_CURRENT_TARGET_FILENAME@")