This repository has been archived by the owner on Apr 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
CMakeLists.txt
127 lines (99 loc) · 4.67 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
cmake_minimum_required(VERSION 3.8)
project(gdalcubes LANGUAGES CXX C VERSION 0.3.2)
#set(COLLECTION_FORMAT_VERSION_MAJOR 0)
#set(COLLECTION_FORMAT_VERSION_MINOR 0)
#set(COLLECTION_FORMAT_VERSION_PATCH 0)
#string(TIMESTAMP build_date "%Y%m%d")
#string(TIMESTAMP build_time "%H%M%S")
if (NOT CMAKE_BUILD_TYPE)
message(STATUS "No build type specified, using Release")
set(CMAKE_BUILD_TYPE Release)
endif ()
#if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") # enable profiling and coverage reports (gcc specific, only for debug)
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg --coverage")
# set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-no-as-needed -lprofiler" )
# set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-no-as-needed -lprofiler")
# set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg --coverage" )
# set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -pg --coverage")
# set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fsanitize=undefined -D_FORTIFY_SOURCE=0")
# set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address -fsanitize=undefined -D_FORTIFY_SOURCE=0")
#endif ( )
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}")
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
#add_definitions(-DBOOST_SYSTEM_NO_DEPRECATED)
#add_definitions(-DBOOST_ERROR_CODE_HEADER_ONLY)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # for clang-tidy
if (WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCURL_STATICLIB")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -DCURL_STATICLIB")
endif ()
# cppcheck
find_program (CPPCHECK NAMES cppcheck)
if(${CPPCHECK-NOTFOUND})
message(WARNING "could not find cppcheck, skipping static code analysis.")
else ()
add_custom_target(cppcheck ALL
COMMAND ${CPPCHECK} --enable=warning,performance --language=c++ src 2> cppcheck.log
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Running Cppcheck" VERBATIM)
set_target_properties(cppcheck PROPERTIES EXCLUDE_FROM_ALL true)
endif()
# code formatting
find_program (CLANG_FORMAT NAMES clang-format)
if(NOT CLANG_FORMAT)
message(WARNING "could not find clang-format, skipping automated source code formatting.")
else ()
file(GLOB ALL_SOURCE_FILES src/*.cpp src/*.h src/test/*.cpp src/test/*.h)
# clang-format -i -style=file $
add_custom_target(clangformat ALL
COMMAND ${CLANG_FORMAT} -i -style=file ${ALL_SOURCE_FILES}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Auto-formatting source code" VERBATIM)
set_target_properties(clangformat PROPERTIES EXCLUDE_FROM_ALL true)
endif()
# code analysis clang-tidy
find_program (CLANG_TIDY NAMES clang-tidy)
if(NOT CLANG_TIDY)
message(WARNING "could not find clang-tidy, skipping static code analysis.")
else ()
file(GLOB ALL_SOURCE_FILES src/*.cpp )
add_custom_target(clangtidy ALL
COMMAND ${CLANG_TIDY} -p ${CMAKE_CURRENT_BINARY_DIR} ${ALL_SOURCE_FILES}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Static code analysis with clang-tidy" VERBATIM)
set_target_properties(clangtidy PROPERTIES EXCLUDE_FROM_ALL true)
endif()
# documentation
find_program (DOXYGEN NAMES doxygen)
if(NOT DOXYGEN)
message(WARNING "could not find doxygen, skipping documentation build")
endif()
find_program (MKDOCS NAMES mkdocs)
if(NOT MKDOCS)
message(WARNING "could not find mkdocs, skipping documentation build")
endif()
if (DOXYGEN AND MKDOCS)
file(GLOB_RECURSE DOC_FILES "doc/mkdocs.yml" "doc/docs/*" )
add_custom_target(docs ALL
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/docs.cmake
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ${DOC_FILES}
COMMENT "Building documentation" VERBATIM)
set_target_properties(docs PROPERTIES EXCLUDE_FROM_ALL true)
endif()
# install collection formats
if ( WIN32 )
install(DIRECTORY formats/ DESTINATION $ENV{AllUsersProfile}/gdalcubes/formats FILES_MATCHING PATTERN "*.json")
else()
install(DIRECTORY formats/ DESTINATION /usr/lib/gdalcubes/formats FILES_MATCHING PATTERN "*.json")
endif()
add_subdirectory(src)
# cpack stuff
set(CPACK_PACKAGE_NAME "gdalcubes")
set(CPACK_PACKAGE_VENDOR "Marius Appel <[email protected]>")
set(CPACK_PACKAGE_CONTACT "Marius Appel <[email protected]>")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "gdalcubes - Earth observation data cubes from GDAL image collections")
set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE)
set(CPACK_RESOURCE_FILE_README ${CMAKE_CURRENT_SOURCE_DIR}/README.md)
include(CPack)