simplify cmake

This commit is contained in:
Mathis Logemann 2022-08-18 20:38:21 +02:00
parent cf78c2a129
commit e6553ef652
17 changed files with 20 additions and 119 deletions

View file

@ -28,7 +28,6 @@ include(CTest)
add_feature_info(BUILD_TESTING BUILD_TESTING "Adds tests")
mapnik_option(INSTALL_DEPENDENCIES "if ON, all dependencies (eg. required dlls) will be copied into CMAKE_INSTALL_PREFIX/MAPNIK_BIN_DIR." ON)
mapnik_option(BUILD_SHARED_LIBS "build mapnik dynamic(ON) or static(OFF)" ON)
mapnik_option(BUILD_SHARED_PLUGINS "build dynamic plugins" ${BUILD_SHARED_LIBS}) # use BUILD_SHARED_LIBS as default option
mapnik_option(BUILD_SHARED_CRT "(only windows with msvc) use msvc shared crt" ON)
@ -94,18 +93,6 @@ mapnik_option(USE_GLIBC_WORKAROUND "see https://github.com/mapnik/mapnik/pull/37
feature_summary(WHAT ENABLED_FEATURES DISABLED_FEATURES)
feature_summary(FILENAME "${CMAKE_CURRENT_BINARY_DIR}/features.log" WHAT ENABLED_FEATURES DISABLED_FEATURES)
set(CMAKE_CXX_STANDARD 14 CACHE STRING "Sets the c++ standard. c++14 is minimum.")
message(STATUS "Using c++${CMAKE_CXX_STANDARD}")
# https://cmake.org/cmake/help/latest/prop_tgt/CXX_EXTENSIONS.html
set(CXX_EXTENSIONS OFF CACHE STRING "Enables the compiler specific extensions.") # Fallsback to -std=c++<ver> if off
message(STATUS "Using c++ extensions: ${CXX_EXTENSIONS}")
# https://cmake.org/cmake/help/latest/prop_tgt/CXX_STANDARD_REQUIRED.html#prop_tgt:CXX_STANDARD_REQUIRED
set(CXX_STANDARD_REQUIRED ON) # require the specified CMAKE_CXX_STANDARD
# add debug postfix to the libraries
set(MAPNIK_DEBUG_POSTFIX "d" CACHE STRING "sets the debug library postfix on mapnik, wkt and json")
message(STATUS "postfix for debug libraries: ${MAPNIK_DEBUG_POSTFIX}")
include(GNUInstallDirs)
# See for more details: https://cmake.org/cmake/help/latest/manual/cmake-buildsystem.7.html
set(MAPNIK_BIN_DIR ${CMAKE_INSTALL_BINDIR} CACHE STRING "Install directory for binaries")
@ -130,7 +117,26 @@ set(MAPNIK_COMPILE_DEFS "")
set(MAPNIK_OPTIONAL_LIBS "")
set(MAPNIK_OPTIONAL_LIBS_INCLUDE "")
#############################
#############################
# Begin project configuration
#############################
#############################
set(CMAKE_CXX_STANDARD 14 CACHE STRING "Sets the c++ standard. c++14 is minimum.")
set(CMAKE_CXX_STANDARD_REQUIRED ON) # require the specified CMAKE_CXX_STANDARD
set(CMAKE_CXX_EXTENSIONS OFF CACHE STRING "Enables the compiler specific extensions.") # Fallsback to -std=c++<ver> if off
message(STATUS "Using c++${CMAKE_CXX_STANDARD}")
message(STATUS "Using c++ extensions: ${CXX_EXTENSIONS}")
# add debug postfix to the libraries
set(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "sets the debug library postfix on mapnik, wkt and json")
message(STATUS "postfix for debug libraries: ${CMAKE_DEBUG_POSTFIX}")
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>$<$<BOOL:${BUILD_SHARED_CRT}>:DLL>")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/lib")
# needs to be before the first call of find_boost.
list(APPEND MAPNIK_COMPILE_DEFS BOOST_SPIRIT_X3_HIDE_CXX17_WARNING)

View file

@ -33,11 +33,7 @@ function(mapnik_create_benchmark)
target_include_directories(${TARGET_NAME} PRIVATE include)
target_link_libraries(${TARGET_NAME} PRIVATE mapnik::agg mapnik::mapnik)
set_target_properties(${TARGET_NAME} PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
ARCHIVE_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/lib"
OUTPUT_NAME "${BENCHNAME}"
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>$<$<BOOL:${BUILD_SHARED_CRT}>:DLL>"
)
endfunction()

View file

@ -1,9 +1,2 @@
add_executable(mapnik-demo rundemo.cpp)
set_target_properties(mapnik-demo PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
ARCHIVE_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/lib"
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>$<$<BOOL:${BUILD_SHARED_CRT}>:DLL>"
)
target_link_libraries(mapnik-demo PRIVATE mapnik::agg mapnik::mapnik)

View file

@ -40,10 +40,6 @@ set_target_properties(mapnik-viewer PROPERTIES
AUTORCC ON
AUTOUIC ON
AUTOMOC ON
LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
ARCHIVE_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/lib"
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>$<$<BOOL:${BUILD_SHARED_CRT}>:DLL>"
)
target_link_libraries(mapnik-viewer PRIVATE

View file

@ -1,8 +1,6 @@
set(_plugin_prefix "")
set(_plugin_suffix ".input")
set(_plugin_library_output "${MAPNIK_OUTPUT_DIR}/plugins/input")
set(_plugin_runtime_output "${MAPNIK_OUTPUT_DIR}")
set(_plugin_archive_output "${MAPNIK_OUTPUT_DIR}/lib")
set(_plugin_fpic ON)
set(_plugin_linkage MODULE)
set(_plugin_visibility PRIVATE)
@ -19,9 +17,6 @@ macro(add_plugin_target plugin_target output_name)
PREFIX "${_plugin_prefix}"
SUFFIX "${_plugin_suffix}"
LIBRARY_OUTPUT_DIRECTORY "${_plugin_library_output}"
RUNTIME_OUTPUT_DIRECTORY "${_plugin_runtime_output}"
ARCHIVE_OUTPUT_DIRECTORY "${_plugin_archive_output}"
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>$<$<BOOL:${BUILD_SHARED_CRT}>:DLL>"
)
mapnik_install_plugin(${plugin_target})
endmacro()

View file

@ -44,17 +44,12 @@ endif()
set_target_properties(mapnik PROPERTIES
POSITION_INDEPENDENT_CODE ON
DEBUG_POSTFIX "${MAPNIK_DEBUG_POSTFIX}"
OUTPUT_NAME "mapnik"
PREFIX "lib"
IMPORT_PREFIX "lib" # for the archive on dll platforms
VERSION ${MAPNIK_VERSION}
# see https://github.com/mapnik/mapnik/pull/4248#issuecomment-925596509 => ABI compability only with the full version
SOVERSION ${MAPNIK_VERSION}
LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
ARCHIVE_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/lib"
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>$<$<BOOL:${BUILD_SHARED_CRT}>:DLL>"
)
if(MSVC)

View file

@ -25,17 +25,12 @@ target_link_libraries(json PRIVATE mapnik::core ${ICUU_LIB})
set_target_properties(json PROPERTIES
POSITION_INDEPENDENT_CODE ON
DEBUG_POSTFIX "${MAPNIK_DEBUG_POSTFIX}"
OUTPUT_NAME "mapnikjson"
PREFIX "lib"
IMPORT_PREFIX "lib"
VERSION ${MAPNIK_VERSION}
# see mapnik target for explanation
SOVERSION ${MAPNIK_VERSION}
LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
ARCHIVE_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/lib"
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>$<$<BOOL:${BUILD_SHARED_CRT}>:DLL>"
)
mapnik_install(json)

View file

@ -17,17 +17,12 @@ target_link_libraries(wkt PRIVATE mapnik::core)
set_target_properties(wkt PROPERTIES
POSITION_INDEPENDENT_CODE ON
DEBUG_POSTFIX "${MAPNIK_DEBUG_POSTFIX}"
OUTPUT_NAME "mapnikwkt"
PREFIX "lib"
IMPORT_PREFIX "lib"
VERSION ${MAPNIK_VERSION}
# see mapnik target for explanation
SOVERSION ${MAPNIK_VERSION}
LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
ARCHIVE_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/lib"
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>$<$<BOOL:${BUILD_SHARED_CRT}>:DLL>"
)
mapnik_install(wkt)

View file

@ -100,12 +100,7 @@ add_executable(mapnik-test-unit
unit/vertex_adapter/transform_path_adapter.cpp
unit/vertex_adapter/vertex_adapter.cpp
)
set_target_properties(mapnik-test-unit PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
ARCHIVE_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/lib"
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>$<$<BOOL:${BUILD_SHARED_CRT}>:DLL>"
)
target_link_libraries(mapnik-test-unit PUBLIC
Catch2::Catch2
mapnik::agg
@ -120,12 +115,6 @@ file(COPY cleanup.hpp DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
target_include_directories(mapnik-test-unit PRIVATE "${Catch2_SOURCE_DIR}/single_include/catch2" "${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}")
add_executable(agg_rasterizer_integer_overflow_test standalone/agg_rasterizer_integer_overflow_test.cpp)
set_target_properties(agg_rasterizer_integer_overflow_test PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
ARCHIVE_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/lib"
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>$<$<BOOL:${BUILD_SHARED_CRT}>:DLL>"
)
target_link_libraries(agg_rasterizer_integer_overflow_test PUBLIC
Catch2::Catch2
mapnik::mapnik
@ -135,12 +124,6 @@ target_link_libraries(agg_rasterizer_integer_overflow_test PUBLIC
target_include_directories(agg_rasterizer_integer_overflow_test PRIVATE "${Catch2_SOURCE_DIR}/single_include/catch2" "${CMAKE_CURRENT_BINARY_DIR}")
add_executable(datasource_registration_test standalone/datasource_registration_test.cpp)
set_target_properties(datasource_registration_test PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
ARCHIVE_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/lib"
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>$<$<BOOL:${BUILD_SHARED_CRT}>:DLL>"
)
target_link_libraries(datasource_registration_test PUBLIC
Catch2::Catch2
mapnik::mapnik
@ -149,12 +132,6 @@ target_link_libraries(datasource_registration_test PUBLIC
target_include_directories(datasource_registration_test PRIVATE "${Catch2_SOURCE_DIR}/single_include/catch2" "${CMAKE_CURRENT_BINARY_DIR}")
add_executable(font_registration_test standalone/font_registration_test.cpp)
set_target_properties(font_registration_test PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
ARCHIVE_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/lib"
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>$<$<BOOL:${BUILD_SHARED_CRT}>:DLL>"
)
target_link_libraries(font_registration_test PUBLIC
Catch2::Catch2
mapnik::mapnik
@ -164,12 +141,6 @@ target_link_libraries(font_registration_test PUBLIC
target_include_directories(font_registration_test PRIVATE "${Catch2_SOURCE_DIR}/single_include/catch2" "${CMAKE_CURRENT_BINARY_DIR}")
add_executable(map_xml_test standalone/map_xml_test.cpp)
set_target_properties(map_xml_test PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
ARCHIVE_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/lib"
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>$<$<BOOL:${BUILD_SHARED_CRT}>:DLL>"
)
target_link_libraries(map_xml_test PUBLIC
Catch2::Catch2
mapnik::mapnik

View file

@ -4,12 +4,6 @@ add_executable(mapnik-test-visual
runner.cpp
run.cpp
)
set_target_properties(mapnik-test-visual PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
ARCHIVE_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/lib"
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>$<$<BOOL:${BUILD_SHARED_CRT}>:DLL>"
)
target_link_libraries(mapnik-test-visual PRIVATE
Catch2::Catch2
Boost::program_options

View file

@ -2,9 +2,4 @@ add_executable(geometry_to_wkb main.cpp)
target_link_libraries(geometry_to_wkb PRIVATE mapnik::mapnik)
set_target_properties(geometry_to_wkb PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>$<$<BOOL:${BUILD_SHARED_CRT}>:DLL>"
)
mapnik_install_utility(geometry_to_wkb)

View file

@ -13,9 +13,4 @@ target_link_libraries(mapnik-index PRIVATE
Boost::program_options
)
set_target_properties(mapnik-index PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>$<$<BOOL:${BUILD_SHARED_CRT}>:DLL>"
)
mapnik_install_utility(mapnik-index)

View file

@ -7,9 +7,4 @@ target_link_libraries(mapnik-render PRIVATE
Boost::program_options
)
set_target_properties(mapnik-render PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>$<$<BOOL:${BUILD_SHARED_CRT}>:DLL>"
)
mapnik_install_utility(mapnik-render)

View file

@ -2,9 +2,4 @@ add_executable(ogrindex ogrindex.cpp)
target_link_libraries(ogrindex PRIVATE mapnik::mapnik)
set_target_properties(ogrindex PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>$<$<BOOL:${BUILD_SHARED_CRT}>:DLL>"
)
mapnik_install_utility(ogrindex)

View file

@ -15,9 +15,4 @@ target_link_libraries(pgsql2sqlite PRIVATE
mapnik::mapnik
)
set_target_properties(pgsql2sqlite PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>$<$<BOOL:${BUILD_SHARED_CRT}>:DLL>"
)
mapnik_install_utility(pgsql2sqlite)

View file

@ -10,9 +10,4 @@ target_link_libraries(shapeindex PRIVATE
mapnik::mapnik
)
set_target_properties(shapeindex PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>$<$<BOOL:${BUILD_SHARED_CRT}>:DLL>"
)
mapnik_install_utility(shapeindex)

View file

@ -10,9 +10,4 @@ target_link_libraries(svg2png PRIVATE
mapnik::agg
)
set_target_properties(svg2png PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>$<$<BOOL:${BUILD_SHARED_CRT}>:DLL>"
)
mapnik_install_utility(svg2png)