2022-04-18 20:24:39 +08:00
|
|
|
cmake_minimum_required(VERSION 3.15)
|
2019-06-20 21:18:58 +08:00
|
|
|
|
|
|
|
set(libBasename JKQTCommon)
|
2019-06-22 22:39:53 +08:00
|
|
|
set(libIncludeSubdir jkqtcommon)
|
2019-06-20 21:18:58 +08:00
|
|
|
|
2019-11-18 22:59:06 +08:00
|
|
|
if(JKQtPlotter_BUILD_SHARED_LIBS)
|
2019-06-22 20:21:32 +08:00
|
|
|
set(libsh_name ${libBasename}SharedLib)
|
2019-11-18 22:59:06 +08:00
|
|
|
set(libsh_name_decorated ${libsh_name}${JKQtPlotter_LIBNAME_ADDITION})
|
2019-06-22 20:21:32 +08:00
|
|
|
set(${libBasename}_SHARED_LIBRARY ${libsh_name_decorated} CACHE STRING "name of static library for ${libBasename}" FORCE)
|
2019-06-20 21:18:58 +08:00
|
|
|
message( STATUS "-- Building ${libsh_name}" )
|
2019-11-18 22:59:06 +08:00
|
|
|
endif(JKQtPlotter_BUILD_SHARED_LIBS)
|
2019-06-20 21:18:58 +08:00
|
|
|
|
2019-11-18 22:59:06 +08:00
|
|
|
if(JKQtPlotter_BUILD_STATIC_LIBS)
|
2019-06-22 20:21:32 +08:00
|
|
|
set(lib_name ${libBasename}Lib)
|
2019-11-18 22:59:06 +08:00
|
|
|
set(lib_name_decorated ${lib_name}${JKQtPlotter_LIBNAME_ADDITION})
|
2019-06-22 20:21:32 +08:00
|
|
|
set(${libBasename}_STATIC_LIBRARY ${lib_name_decorated} CACHE STRING "name of static library for ${libBasename}" FORCE)
|
2019-06-20 21:18:58 +08:00
|
|
|
message( STATUS "-- Building ${lib_name}" )
|
2019-11-18 22:59:06 +08:00
|
|
|
endif(JKQtPlotter_BUILD_STATIC_LIBS)
|
2019-06-20 21:18:58 +08:00
|
|
|
|
2019-11-18 22:59:06 +08:00
|
|
|
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
|
2019-06-20 21:18:58 +08:00
|
|
|
|
|
|
|
# Set up source files
|
2019-06-21 04:24:47 +08:00
|
|
|
set(SOURCES
|
2022-04-18 20:24:39 +08:00
|
|
|
${CMAKE_CURRENT_LIST_DIR}/jkqtpdebuggingtools.cpp
|
|
|
|
${CMAKE_CURRENT_LIST_DIR}/jkqtpmathtools.cpp
|
|
|
|
${CMAKE_CURRENT_LIST_DIR}/jkqtpstringtools.cpp
|
|
|
|
${CMAKE_CURRENT_LIST_DIR}/jkqtpcodestructuring.cpp
|
|
|
|
${CMAKE_CURRENT_LIST_DIR}/jkqtpbasicimagetools.cpp
|
2023-06-25 23:55:05 +08:00
|
|
|
${CMAKE_CURRENT_LIST_DIR}/jkqtpconcurrencytools.cpp
|
2022-04-18 20:24:39 +08:00
|
|
|
${CMAKE_CURRENT_LIST_DIR}/jkqtpgeometrytools.cpp
|
|
|
|
${CMAKE_CURRENT_LIST_DIR}/jkqtpdrawingtools.cpp
|
|
|
|
${CMAKE_CURRENT_LIST_DIR}/jkqtpenhancedpainter.cpp
|
|
|
|
${CMAKE_CURRENT_LIST_DIR}/jkqtphighrestimer.cpp
|
|
|
|
${CMAKE_CURRENT_LIST_DIR}/jkqttools.cpp
|
2022-06-03 03:21:51 +08:00
|
|
|
${CMAKE_CURRENT_LIST_DIR}/jkqtpicons.cpp
|
2019-05-18 19:23:38 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
set(HEADERS
|
2022-04-18 20:24:39 +08:00
|
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/jkqtcommon_imexport.h>
|
|
|
|
$<INSTALL_INTERFACE:jkqtcommon_imexport.h>
|
|
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/jkqtpdebuggingtools.h>
|
|
|
|
$<INSTALL_INTERFACE:jkqtpdebuggingtools.h>
|
2022-08-22 23:36:49 +08:00
|
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/jkqtpmathtools.h>
|
|
|
|
$<INSTALL_INTERFACE:jkqtpmathtools.h>
|
2022-04-18 20:24:39 +08:00
|
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/jkqtpstringtools.h>
|
|
|
|
$<INSTALL_INTERFACE:jkqtpstringtools.h>
|
|
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/jkqtpcodestructuring.h>
|
|
|
|
$<INSTALL_INTERFACE:jkqtpcodestructuring.h>
|
|
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/jkqtpbasicimagetools.h>
|
|
|
|
$<INSTALL_INTERFACE:jkqtpbasicimagetools.h>
|
|
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/jkqtpdrawingtools.h>
|
|
|
|
$<INSTALL_INTERFACE:jkqtpdrawingtools.h>
|
|
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/jkqtpenhancedpainter.h>
|
|
|
|
$<INSTALL_INTERFACE:jkqtpenhancedpainter.h>
|
|
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/jkqtphighrestimer.h>
|
|
|
|
$<INSTALL_INTERFACE:jkqtphighrestimer.h>
|
|
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/jkqttools.h>
|
|
|
|
$<INSTALL_INTERFACE:jkqttools.h>
|
2022-06-03 03:21:51 +08:00
|
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/jkqtpicons.h>
|
|
|
|
$<INSTALL_INTERFACE:jkqtpicons.h>
|
2022-08-22 23:36:49 +08:00
|
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/jkqtpgeometrytools.h>
|
|
|
|
$<INSTALL_INTERFACE:jkqtpgeometrytools.h>
|
2023-06-25 23:55:05 +08:00
|
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/jkqtpconcurrencytools.h>
|
|
|
|
$<INSTALL_INTERFACE:jkqtpconcurrencytools.h>
|
2019-06-20 21:18:58 +08:00
|
|
|
)
|
|
|
|
|
2019-06-22 22:39:53 +08:00
|
|
|
include(CMakePackageConfigHelpers)
|
|
|
|
|
2022-07-19 05:33:20 +08:00
|
|
|
function(JKQtCommon_setDefaultLibOptions TARGETNAME)
|
|
|
|
set_property(TARGET ${TARGETNAME} PROPERTY VERSION "${PROJECT_VERSION}")
|
|
|
|
target_link_libraries(${TARGETNAME} PUBLIC Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Gui Qt${QT_VERSION_MAJOR}::Xml Qt${QT_VERSION_MAJOR}::Widgets)
|
2022-07-23 19:59:23 +08:00
|
|
|
set_property(TARGET ${TARGETNAME} PROPERTY CXX_STANDARD ${JKQtPlotter_QT_CXX_STANDARD})
|
|
|
|
set_property(TARGET ${TARGETNAME} PROPERTY CXX_STANDARD_REQUIRED ${JKQtPlotter_QT_CXX_STANDARD_REQUIRED})
|
|
|
|
target_compile_features(${TARGETNAME} PUBLIC ${JKQtPlotter_QT_CXX_COMPILE_FEATURE})
|
2020-06-28 21:53:26 +08:00
|
|
|
if(MINGW)
|
|
|
|
# COMPILER-SETTINGS FOR MINGW
|
2022-07-19 05:33:20 +08:00
|
|
|
target_compile_options(${TARGETNAME} PUBLIC -fexceptions)
|
2020-06-28 21:53:26 +08:00
|
|
|
elseif(MSVC)
|
|
|
|
# COMPILER-SETTINGS FOR MS VISUAL C++
|
2022-07-19 05:33:20 +08:00
|
|
|
target_compile_options(${TARGETNAME} PUBLIC /EHsc)
|
|
|
|
target_compile_definitions(${TARGETNAME} PUBLIC NOMINMAX)
|
2020-06-28 21:53:26 +08:00
|
|
|
endif()
|
2022-07-19 05:33:20 +08:00
|
|
|
target_include_directories(${TARGETNAME} PUBLIC
|
2022-04-18 20:24:39 +08:00
|
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/../>
|
2022-07-19 05:33:20 +08:00
|
|
|
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
2019-11-18 22:59:06 +08:00
|
|
|
)
|
2022-07-21 04:31:42 +08:00
|
|
|
# precomiled headers to speed up compilation
|
2022-07-23 03:41:07 +08:00
|
|
|
if (JKQtPlotter_BUILD_WITH_PRECOMPILED_HEADERS)
|
|
|
|
target_precompile_headers(${TARGETNAME} PRIVATE ${CMAKE_CURRENT_LIST_DIR}/private/jkqtcommon_precomp.h)
|
|
|
|
target_sources(${TARGETNAME} PRIVATE ${CMAKE_CURRENT_LIST_DIR}/private/jkqtcommon_precomp.h)
|
|
|
|
endif(JKQtPlotter_BUILD_WITH_PRECOMPILED_HEADERS)
|
2022-07-19 05:33:20 +08:00
|
|
|
endfunction()
|
|
|
|
|
|
|
|
|
|
|
|
if(JKQtPlotter_BUILD_SHARED_LIBS)
|
|
|
|
add_library(${libsh_name} SHARED ${SOURCES} ${HEADERS} )
|
|
|
|
JKQtCommon_setDefaultLibOptions(${libsh_name})
|
|
|
|
set_property(TARGET ${libsh_name} PROPERTY OUTPUT_NAME "${libsh_name_decorated}")
|
|
|
|
target_compile_definitions(${libsh_name} PUBLIC JKQTCOMMON_LIB_IN_DLL)
|
|
|
|
target_compile_definitions(${libsh_name} PRIVATE JKQTCOMMON_LIB_EXPORT_LIBRARY)
|
2019-11-22 04:42:10 +08:00
|
|
|
set_target_properties(${libsh_name} PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS "ON")
|
2019-06-22 22:39:53 +08:00
|
|
|
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/${libsh_name}Version.cmake
|
|
|
|
VERSION ${PROJECT_VERSION}
|
2022-04-19 05:10:05 +08:00
|
|
|
COMPATIBILITY AnyNewerVersion )
|
2019-06-20 21:18:58 +08:00
|
|
|
endif()
|
|
|
|
|
2019-11-18 22:59:06 +08:00
|
|
|
if(JKQtPlotter_BUILD_STATIC_LIBS)
|
2022-04-18 20:24:39 +08:00
|
|
|
add_library(${lib_name} STATIC ${SOURCES} ${HEADERS})
|
2022-07-19 05:33:20 +08:00
|
|
|
JKQtCommon_setDefaultLibOptions(${lib_name})
|
2019-06-22 20:21:32 +08:00
|
|
|
set_property(TARGET ${lib_name} PROPERTY OUTPUT_NAME "${lib_name_decorated}")
|
2019-06-22 22:39:53 +08:00
|
|
|
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/${lib_name}Version.cmake
|
|
|
|
VERSION ${PROJECT_VERSION}
|
|
|
|
COMPATIBILITY AnyNewerVersion )
|
2019-06-20 21:18:58 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Installation
|
2019-11-18 22:59:06 +08:00
|
|
|
if(JKQtPlotter_BUILD_SHARED_LIBS)
|
2022-10-06 17:54:18 +08:00
|
|
|
jkqtplotter_installlibrary(${libsh_name} ${libIncludeSubdir} "Shared")
|
2020-06-28 21:53:26 +08:00
|
|
|
endif(JKQtPlotter_BUILD_SHARED_LIBS)
|
|
|
|
|
|
|
|
if(JKQtPlotter_BUILD_STATIC_LIBS)
|
2022-10-06 17:54:18 +08:00
|
|
|
jkqtplotter_installlibrary(${lib_name} ${libIncludeSubdir} "")
|
2020-06-28 21:53:26 +08:00
|
|
|
endif(JKQtPlotter_BUILD_STATIC_LIBS)
|
|
|
|
|
|
|
|
install(FILES ${HEADERS}
|
|
|
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${libIncludeSubdir}
|
|
|
|
COMPONENT Headers)
|
|
|
|
|
2022-10-06 03:52:19 +08:00
|
|
|
|
2022-08-23 02:35:24 +08:00
|
|
|
configure_file(${PROJECT_SOURCE_DIR}/readme.txt.in ${CMAKE_CURRENT_BINARY_DIR}/${libBasename}_Readme.txt @ONLY)
|
|
|
|
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${libBasename}_Readme.txt" DESTINATION doc/JKQtPlotter )
|
|
|
|
install(FILES "${PROJECT_SOURCE_DIR}/LICENSE" DESTINATION doc/JKQtPlotter RENAME "${libBasename}_LICENSE.txt" )
|
2019-11-18 22:59:06 +08:00
|
|
|
|