From 02180115bfb0fa91e45b02d48cd54c37865079d7 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Wed, 25 Aug 2021 16:41:57 +0200 Subject: [PATCH] some last minor improvements --- CMakeLists.txt | 2 +- CMakePresets.json | 164 ++++++++++++++++++++++++++-------------- docs/cmake-usage.md | 6 ++ src/CMakeLists.txt | 15 ++-- src/json/CMakeLists.txt | 3 +- src/wkt/CMakeLists.txt | 3 +- 6 files changed, 127 insertions(+), 66 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ef7bb19af..4c6ba296b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,7 +22,7 @@ include(MapnikCopyDependencies) include(MapnikInstall) set(ADDITIONAL_LIBARIES_PATHS "" CACHE STRING "only used on windows. Pass directories containing the dlls that are missing. You can ignore this, if the build (verify_app step) runs successfully") -option(COPY_LIBRARIES_FOR_EXECUTABLES "copies required shared libaries (only windows) to the executable build directory" ON) +option(COPY_LIBRARIES_FOR_EXECUTABLES "copies required shared libaries (only windows) to the executable build directory" OFF) option(COPY_FONTS_AND_PLUGINS_FOR_EXECUTABLES "copies required plugins and fonts into the executable build directory" ON) option(INSTALL_DEPENDENCIES "if ON, all dependencies (eg. required dlls) will be copied into CMAKE_INSTALL_PREFIX/MAPNIK_BIN_DIR." ON) diff --git a/CMakePresets.json b/CMakePresets.json index 06a43f192..5f2a874f0 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -7,11 +7,41 @@ }, "configurePresets": [ { - "name": "linux-clang", - "displayName": "Linux clang", + "name": "use-ninja", "hidden": true, - "binaryDir": "${sourceDir}/build/${presetName}", - "generator": "Ninja", + "generator": "Ninja" + }, + { + "name": "default-build-dir", + "hidden": true, + "binaryDir": "${sourceDir}/build/${presetName}" + }, + { + "name": "debug-build", + "hidden": true, + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug", + "USE_DEBUG_OUTPUT": "ON", + "USE_LOG": "ON", + "USE_LOG_SEVERITY": "0" + } + }, + { + "name": "release-build", + "hidden": true, + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release", + "USE_DEBUG_OUTPUT": "OFF", + "USE_LOG": "OFF" + } + }, + { + "name": "use-clang", + "hidden": true, + "inherits": [ + "default-build-dir", + "use-ninja" + ], "cacheVariables": { "CMAKE_C_COMPILER": "clang", "CMAKE_CXX_COMPILER": "clang++", @@ -21,60 +51,76 @@ } }, { - "name": "linux-clang-debug", - "displayName": "Linux clang debug", - "inherits": "linux-clang", - "cacheVariables": { - "CMAKE_BUILD_TYPE": "Debug", - "USE_DEBUG_OUTPUT": "ON", - "USE_LOG": "ON", - "USE_LOG_SEVERITY": "0" - } - }, - { - "name": "linux-clang-release", - "displayName": "Linux clang release", - "inherits": "linux-clang", - "cacheVariables": { - "CMAKE_BUILD_TYPE": "Release" - } - }, - { - "name": "linux-gcc", - "displayName": "Linux gcc", + "name": "use-gcc", "hidden": true, - "binaryDir": "${sourceDir}/build/${presetName}", - "generator": "Ninja", + "inherits": [ + "default-build-dir", + "use-ninja" + ], "cacheVariables": { "CMAKE_C_COMPILER": "gcc", "CMAKE_CXX_COMPILER": "g++" } }, + { + "name": "use-msvc-cl", + "hidden": true, + "inherits": [ + "default-build-dir", + "use-ninja" + ], + "cacheVariables": { + "CMAKE_C_COMPILER": "cl", + "CMAKE_CXX_COMPILER": "cl" + } + }, + { + "name": "use-msvc-clang-cl", + "hidden": true, + "inherits": [ + "default-build-dir", + "use-ninja" + ], + "cacheVariables": { + "CMAKE_C_COMPILER": "clang-cl", + "CMAKE_CXX_COMPILER": "clang-cl" + } + }, + { + "name": "linux-clang-debug", + "displayName": "Linux clang debug", + "inherits": [ + "use-clang", + "debug-build" + ] + }, + { + "name": "linux-clang-release", + "displayName": "Linux clang release", + "inherits": [ + "use-clang", + "release-build" + ] + }, { "name": "linux-gcc-debug", "displayName": "Linux gcc debug", - "inherits": "linux-gcc", - "cacheVariables": { - "CMAKE_BUILD_TYPE": "Debug", - "USE_DEBUG_OUTPUT": "ON", - "USE_LOG": "ON", - "USE_LOG_SEVERITY": "0" - } + "inherits": [ + "use-gcc", + "debug-build" + ] }, { "name": "linux-gcc-release", "displayName": "Linux gcc release", - "inherits": "linux-gcc", - "cacheVariables": { - "CMAKE_BUILD_TYPE": "Release" - } + "inherits": [ + "use-gcc", + "release-build" + ] }, { - "name": "windows-default", - "displayName": "Windows x64 Debug", + "name": "windows-arch-x64", "hidden": true, - "generator": "Ninja", - "binaryDir": "${sourceDir}/build/${presetName}", "architecture": { "value": "x64", "strategy": "external" @@ -82,11 +128,16 @@ "toolset": { "value": "host=x64", "strategy": "external" - }, - "cacheVariables": { - "CMAKE_C_COMPILER": "cl", - "CMAKE_CXX_COMPILER": "cl" - }, + } + }, + { + "name": "windows-default", + "displayName": "Windows x64 Debug", + "hidden": true, + "inherits": [ + "use-msvc-cl", + "windows-arch-x64" + ], "vendor": { "microsoft.com/VisualStudioSettings/CMake/1.0": { "hostOS": [ @@ -98,21 +149,18 @@ { "name": "windows-default-debug", "displayName": "Windows x64 Debug", - "inherits": "windows-default", - "cacheVariables": { - "CMAKE_BUILD_TYPE": "Debug", - "USE_DEBUG_OUTPUT": "ON", - "USE_LOG": "ON", - "USE_LOG_SEVERITY": "0" - } + "inherits": [ + "windows-default", + "debug-build" + ] }, { "name": "windows-default-release", "displayName": "Windows x64 Release", - "inherits": "windows-default", - "cacheVariables": { - "CMAKE_BUILD_TYPE": "Release" - } + "inherits": [ + "windows-default", + "release-build" + ] } ], "buildPresets": [ diff --git a/docs/cmake-usage.md b/docs/cmake-usage.md index 22ff34086..f3cfbcf05 100644 --- a/docs/cmake-usage.md +++ b/docs/cmake-usage.md @@ -96,3 +96,9 @@ If your libraries are not in the global search paths, you could add a own `CMake ] } ``` + +Build with: +``` +$ cmake --preset +$ cmake --build --preset +``` diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5de2a86e6..c2679f065 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,10 +1,6 @@ add_subdirectory(json) add_subdirectory(wkt) -if(MSVC) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj") -endif() - set(MAPNIK_SOURCES cairo_io.cpp color_factory.cpp @@ -296,10 +292,19 @@ target_link_libraries(mapnik PRIVATE ) set_target_properties(mapnik PROPERTIES - DEBUG_POSTFIX ${MAPNIK_DEBUG_POSTFIX} + DEBUG_POSTFIX "${MAPNIK_DEBUG_POSTFIX}" + OUTPUT_NAME "mapnik" PREFIX "lib" ) +if(MSVC) + # disable some msvc warnings and enable bigobj + # 4068 will warn about unknown definitions. Would not be needed if https://github.com/mapbox/geometry.hpp/pull/69 is merged. + # 4661 warns about enum definitions. should be investigated at some point + # 4910 warns about extern and dllexport at the same time. should be investigated at some point + target_compile_options(mapnik PUBLIC "/bigobj" "/wd4068" "/wd4661" "/wd4910") +endif() + install(TARGETS mapnik EXPORT MapnikTargets LIBRARY DESTINATION ${MAPNIK_LIB_DIR} diff --git a/src/json/CMakeLists.txt b/src/json/CMakeLists.txt index 93f0baad7..0748d2043 100644 --- a/src/json/CMakeLists.txt +++ b/src/json/CMakeLists.txt @@ -25,8 +25,9 @@ target_include_directories(json PRIVATE target_link_libraries(json PRIVATE mapnik::core ${ICUU_LIB}) set_target_properties(json PROPERTIES - DEBUG_POSTFIX ${MAPNIK_DEBUG_POSTFIX} POSITION_INDEPENDENT_CODE ON + DEBUG_POSTFIX "${MAPNIK_DEBUG_POSTFIX}" + OUTPUT_NAME "json" PREFIX "libmapnik-" ) diff --git a/src/wkt/CMakeLists.txt b/src/wkt/CMakeLists.txt index 7ef2255fa..9c0934290 100644 --- a/src/wkt/CMakeLists.txt +++ b/src/wkt/CMakeLists.txt @@ -17,8 +17,9 @@ target_include_directories(wkt PRIVATE target_link_libraries(wkt PRIVATE mapnik::core) set_target_properties(wkt PROPERTIES - DEBUG_POSTFIX ${MAPNIK_DEBUG_POSTFIX} POSITION_INDEPENDENT_CODE ON + DEBUG_POSTFIX "${MAPNIK_DEBUG_POSTFIX}" + OUTPUT_NAME "wkt" PREFIX "libmapnik-" )