add presets

This commit is contained in:
Mathis Logemann 2021-07-22 22:45:39 +02:00
parent 4d3affb95d
commit d737569574
4 changed files with 170 additions and 6 deletions

2
.gitignore vendored
View file

@ -60,3 +60,5 @@ test/visual/run
# cmake # cmake
build build
.vs .vs
CMakeUserPresets.json

View file

@ -266,9 +266,9 @@ endif()
if(USE_PROJ) if(USE_PROJ)
#https://proj.org/development/cmake.html #https://proj.org/development/cmake.html
mapnik_find_package(PROJ QUIET) mapnik_find_package(PROJ4 QUIET)
# currently the cmake files are not installed, when installing proj via apt-get. So search via pkg-config # currently the cmake files are not installed, when installing proj via apt-get. So search via pkg-config
if(NOT PROJ_FOUND) if(NOT PROJ4_FOUND)
message(STATUS "PROJ not found via FindPROJ. Searching via pkg-config...") message(STATUS "PROJ not found via FindPROJ. Searching via pkg-config...")
pkg_check_modules(PROJ REQUIRED IMPORTED_TARGET proj) pkg_check_modules(PROJ REQUIRED IMPORTED_TARGET proj)
string(REGEX MATCH "([0-9]+)\.([0-9]+)\.([0-9]+)" _dummy "${PROJ_VERSION}") string(REGEX MATCH "([0-9]+)\.([0-9]+)\.([0-9]+)" _dummy "${PROJ_VERSION}")
@ -276,11 +276,11 @@ if(USE_PROJ)
set(PROJ_VERSION_MINOR "${CMAKE_MATCH_2}") set(PROJ_VERSION_MINOR "${CMAKE_MATCH_2}")
set(PROJ_VERSION_PATCH "${CMAKE_MATCH_3}") set(PROJ_VERSION_PATCH "${CMAKE_MATCH_3}")
endif() endif()
math(EXPR MAPNIK_PROJ_VERSION "${PROJ_VERSION_MAJOR}*10000 + ${PROJ_VERSION_MINOR}*100 + ${PROJ_VERSION_PATCH}" OUTPUT_FORMAT DECIMAL) math(EXPR MAPNIK_PROJ_VERSION "${PROJ4_VERSION_MAJOR}*10000 + ${PROJ4_VERSION_MINOR}*100 + ${PROJ4_VERSION_PATCH}" OUTPUT_FORMAT DECIMAL)
message(STATUS "Using mapnik PROJ version: ${MAPNIK_PROJ_VERSION}") message(STATUS "Using mapnik PROJ version: ${MAPNIK_PROJ_VERSION}")
list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_USE_PROJ MAPNIK_PROJ_VERSION=${MAPNIK_PROJ_VERSION}) list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_USE_PROJ MAPNIK_PROJ_VERSION=${MAPNIK_PROJ_VERSION})
list(APPEND MAPNIK_OPTIONAL_LIBS ${PROJ_LIBRARIES}) list(APPEND MAPNIK_OPTIONAL_LIBS ${PROJ4_LIBRARIES})
list(APPEND MAPNIK_OPTIONAL_LIBS_INCLUDE ${PROJ_INCLUDE_DIRS}) list(APPEND MAPNIK_OPTIONAL_LIBS_INCLUDE ${PROJ4_INCLUDE_DIRS})
endif() endif()
if(USE_GRID_RENDERER) if(USE_GRID_RENDERER)

105
CMakePresets.json Normal file
View file

@ -0,0 +1,105 @@
{
"version": 2,
"cmakeMinimumRequired": {
"major": 3,
"minor": 20,
"patch": 0
},
"configurePresets": [
{
"name": "linux-clang",
"displayName": "Linux clang",
"hidden": true,
"binaryDir": "${sourceDir}/build/${presetName}",
"cacheVariables": {
"CMAKE_C_COMPILER": "clang",
"CMAKE_CXX_COMPILER": "clang++",
"CMAKE_CXX_FLAGS": "-stdlib=libstdc++",
"CMAKE_EXE_LINKER_FLAGS": "-stdlib=libstdc++",
"CMAKE_SHARED_LINKER_FLAGS": "-stdlib=libstdc++"
}
},
{
"name": "linux-clang-debug",
"displayName": "Linux clang debug",
"inherits": "linux-clang",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "linux-clang-release",
"displayName": "Linux clang release",
"inherits": "linux-clang",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "linux-gcc",
"displayName": "Linux gcc",
"hidden": true,
"binaryDir": "${sourceDir}/build/${presetName}",
"cacheVariables": {
"CMAKE_C_COMPILER": "gcc",
"CMAKE_CXX_COMPILER": "g++"
}
},
{
"name": "linux-gcc-debug",
"displayName": "Linux gcc debug",
"inherits": "linux-gcc",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "linux-gcc-release",
"displayName": "Linux gcc release",
"inherits": "linux-gcc",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "windows-default",
"displayName": "Windows x64 Debug",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build/${presetName}",
"architecture": {
"value": "x64",
"strategy": "external"
},
"toolset": {
"value": "host=x64",
"strategy": "external"
},
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_C_COMPILER": "cl",
"CMAKE_CXX_COMPILER": "cl"
},
"vendor": {
"microsoft.com/VisualStudioSettings/CMake/1.0": {
"hostOS": [
"Windows"
]
}
}
},
{
"name": "windows-default-release",
"displayName": "Windows x64 Release",
"inherits": "windows-default",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
}
],
"buildPresets": [
{
"name": "default",
"configurePreset": "default"
}
]
}

View file

@ -36,4 +36,61 @@ The font path is is available in the variable `MAPNIK_FONTS_DIR`.
## Recommendations ## Recommendations
If you target a specific platform, it is recommended to create a toolchain file and set all the options and library path that you would normally set via cmd line options. If you target a specific platform, it is recommended to create a toolchain file and set all the options and library path that you would normally set via cmd line options.
If you are using a recent cmake version (>=3.19?), it is recommended to use a CMakePreset instead. https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html If you are using a recent cmake version (>=3.20), it is recommended to use a CMakePreset instead. https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html
## CMakePreset example
If you are using CMakePresets and need to add vcpkg integration, just create a `CMakeUserPresets.json` file beside `CMakePresets.json.
This could look like this:
```json
{
"version": 2,
"cmakeMinimumRequired": {
"major": 3,
"minor": 20,
"patch": 0
},
"configurePresets": [
{
"name": "vcpkg-x64-win-debug",
"inherits": "windows-default",
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": "D:/dev/vcpkg/scripts/buildsystems/vcpkg.cmake"
}
},
{
"name": "vcpkg-x64-win-release",
"inherits": "windows-default-release",
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": "D:/dev/vcpkg/scripts/buildsystems/vcpkg.cmake"
}
}
]
}
```
If your libraries are not in the global search paths, you could add a own `CMakeUserPresets.json` with
```json
{
"version": 2,
"cmakeMinimumRequired": {
"major": 3,
"minor": 20,
"patch": 0
},
"configurePresets": [
{
"name": "linux-clang-debug-own",
"inherits": "linux-clang-debug",
"cacheVariables": {
"WebP_DIR": "/home/myuser/webp/cmake",
"USE_CAIRO": "OFF",
"CMAKE_INSTALL_PREFIX": "${sourceDir}/install"
}
}
]
}
```