|
1 | 1 | cmake_minimum_required(VERSION 3.8) |
2 | 2 | project(delaunator VERSION 0.4.0) |
3 | | -set (CMAKE_CXX_STANDARD 14) |
4 | | -set(CMAKE_CXX_STANDARD_REQUIRED on) |
5 | | -set(CMAKE_EXPORT_COMPILE_COMMANDS ON) |
6 | 3 |
|
7 | | -include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/mason.cmake) |
| 4 | +set(ROOT_DIR ${PROJECT_SOURCE_DIR}) |
8 | 5 |
|
9 | | -option(WERROR "Add -Werror flag to build (turns warnings into errors)" ON) |
10 | | -option(BENCHMARK_BIG_O "Calculate Big O in benchmark" OFF) |
11 | | -option(BENCHMARK_100M "Run against 100M points" OFF) |
12 | | -option(BENCHMARK_10M "Run against 100M points" OFF) |
| 6 | +# |
| 7 | +# Must be first. |
| 8 | +# |
| 9 | +include(${ROOT_DIR}/cmake/common.cmake NO_POLICY_SCOPE) |
13 | 10 |
|
14 | | -# configure optimization |
15 | | -if (CMAKE_BUILD_TYPE STREQUAL "Debug") |
16 | | - set(OPTIMIZATION_FLAGS "-O0 -DDEBUG") |
17 | | - message("-- Configuring debug build") |
18 | | -else() |
19 | | - set(OPTIMIZATION_FLAGS "-O3 -DNDEBUG") |
20 | | - message("-- Configuring release build") |
21 | | -endif() |
| 11 | +include(CTest) |
| 12 | +include(FeatureSummary) |
22 | 13 |
|
23 | | -# Enable extra warnings to adhere to https://github.com/mapbox/cpp/issues/37 |
24 | | -set(DESIRED_WARNINGS "-Wall -Wextra -Wconversion -Wunreachable-code -Wuninitialized -pedantic-errors -Wold-style-cast -Wno-error=unused-variable -Wshadow -Wfloat-equal -Weffc++") |
25 | | -if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") |
26 | | - set(DESIRED_WARNINGS "${DESIRED_WARNINGS} -Wmost") |
27 | | -endif() |
| 14 | +include(${D_CMAKE_DIR}/options.cmake) |
| 15 | +include(${D_CMAKE_DIR}/gtest.cmake) |
28 | 16 |
|
29 | | -# Note: -D_GLIBCXX_USE_CXX11_ABI=0 is needed to support mason packages that are precompiled libs |
30 | | -# Currently we only depend on a header only library, but this will help avoid issues when more libs are added via mason |
31 | | -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OPTIMIZATION_FLAGS} -D_GLIBCXX_USE_CXX11_ABI=0 ${DESIRED_WARNINGS}") |
| 17 | +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${D_BIN_DIR}) |
32 | 18 |
|
33 | | -if (WERROR) |
34 | | - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror") |
35 | | -endif() |
| 19 | +add_library(delaunator include/delaunator.cpp) |
| 20 | +d_target_compile_settings(delaunator) |
36 | 21 |
|
37 | | -# mason_use is a mason function within the mason.cmake file and provides ready-to-go vars, like "STATIC_LIBS" and "INCLUDE_DIRS" |
38 | | -mason_use(catch VERSION 2.4.0 HEADER_ONLY) |
39 | | -include_directories(SYSTEM ${MASON_PACKAGE_catch_INCLUDE_DIRS}) |
40 | | - |
41 | | -mason_use(rapidjson VERSION 1.1.0 HEADER_ONLY) |
42 | | -include_directories(SYSTEM ${MASON_PACKAGE_rapidjson_INCLUDE_DIRS}) |
43 | | - |
44 | | -mason_use(benchmark VERSION 1.2.0) |
45 | | -include_directories(SYSTEM ${MASON_PACKAGE_benchmark_INCLUDE_DIRS}) |
46 | | - |
47 | | -include_directories("${PROJECT_SOURCE_DIR}/include") |
48 | | - |
49 | | -file(GLOB TEST_SOURCES test/*.cpp) |
50 | | -set(TEST_SOURCES ${TEST_SOURCES} include/delaunator.cpp) |
51 | | -add_executable(unit-tests ${TEST_SOURCES}) |
52 | | - |
53 | | -file(GLOB TEST_SOURCES test-header-only/*.cpp) |
54 | | -add_executable(header-only-unit-tests ${TEST_SOURCES}) |
55 | | - |
56 | | -# libbenchmark.a supports threads and therefore needs pthread support |
57 | | -find_package(Threads REQUIRED) |
58 | | -file(GLOB BENCH_SOURCES bench/*.cpp) |
59 | | -set(BENCH_SOURCES ${BENCH_SOURCES} include/delaunator.cpp) |
60 | | -add_executable(bench-tests ${BENCH_SOURCES}) |
61 | | -if(BENCHMARK_BIG_O) |
62 | | - message("-- BENCHMARK_BIG_O=1") |
63 | | - target_compile_definitions(bench-tests PUBLIC BENCHMARK_BIG_O=1) |
64 | | -endif() |
65 | | -if(BENCHMARK_100M) |
66 | | - message("-- BENCHMARK_100M=1") |
67 | | - target_compile_definitions(bench-tests PUBLIC BENCHMARK_100M=1) |
68 | | -endif() |
69 | | -if(BENCHMARK_10M) |
70 | | - message("-- BENCHMARK_10M=1") |
71 | | - target_compile_definitions(bench-tests PUBLIC BENCHMARK_10M=1) |
72 | | -endif() |
| 22 | +add_subdirectory(test) |
73 | 23 |
|
74 | 24 | #examples |
75 | | -add_executable(triangulate-geojson examples/triangulate_geojson.cpp include/delaunator.cpp) |
76 | | -add_executable(basic examples/basic.cpp include/delaunator.cpp) |
77 | | - |
78 | | - |
79 | | -# link benchmark static library to the bench-tests binary so the bench tests know where to find the benchmark impl code |
80 | | -target_link_libraries(bench-tests ${MASON_PACKAGE_benchmark_STATIC_LIBS} ${CMAKE_THREAD_LIBS_INIT}) |
| 25 | +#add_executable(triangulate-geojson examples/triangulate_geojson.cpp include/delaunator.cpp) |
| 26 | +#add_executable(basic examples/basic.cpp include/delaunator.cpp) |
81 | 27 |
|
82 | | -set(CPACK_PROJECT_NAME ${PROJECT_NAME}) |
83 | | -set(CPACK_PROJECT_VERSION ${PROJECT_VERSION}) |
| 28 | +#set(CPACK_PROJECT_NAME ${PROJECT_NAME}) |
| 29 | +#set(CPACK_PROJECT_VERSION ${PROJECT_VERSION}) |
0 commit comments