-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
94 lines (84 loc) · 3.51 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
cmake_minimum_required(VERSION 3.27)
project(FusswegDatentools VERSION 1.0.0)
# Specify output binary names
set(OUT_BIN_NAME "fdt")
set(TEST_BIN_NAME "fdt_test")
# Specify the C++ standard
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED True)
# Specify the compilers
set(CMAKE_C_COMPILER ${CC})
set(CMAKE_CXX_COMPILER ${CXX})
# Force CMake to use ld.lld, and set linker flags
set(CMAKE_LINKER "${LD}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=lld")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fuse-ld=lld")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -fuse-ld=lld")
# -----------------------------------------------------------------------------
# Main executable
# -----------------------------------------------------------------------------
# define sources and headers
set(SOURCES
"${FusswegDatentools_SOURCE_DIR}/src/main.cpp"
"${FusswegDatentools_SOURCE_DIR}/src/annot.cpp"
"${FusswegDatentools_SOURCE_DIR}/src/img.cpp"
"${FusswegDatentools_SOURCE_DIR}/src/ibox.cpp"
"${FusswegDatentools_SOURCE_DIR}/src/ibox_via.cpp"
"${FusswegDatentools_SOURCE_DIR}/src/crs.cpp"
"${FusswegDatentools_SOURCE_DIR}/src/cv.cpp"
"${FusswegDatentools_SOURCE_DIR}/src/exif.cpp"
"${FusswegDatentools_SOURCE_DIR}/src/gis.cpp"
)
set(HEADERS
"${FusswegDatentools_SOURCE_DIR}/include/annot.hpp"
"${FusswegDatentools_SOURCE_DIR}/include/img.hpp"
"${FusswegDatentools_SOURCE_DIR}/include/ibox.hpp"
"${FusswegDatentools_SOURCE_DIR}/include/crs.hpp"
"${FusswegDatentools_SOURCE_DIR}/include/cv.hpp"
"${FusswegDatentools_SOURCE_DIR}/include/exif.hpp"
"${FusswegDatentools_SOURCE_DIR}/include/gis.hpp"
"${FusswegDatentools_SOURCE_DIR}/include/utils.hpp"
)
# Create the executable
add_executable(${OUT_BIN_NAME}
${SOURCES}
${HEADERS}
)
# Set the runtime output directory to be inside the build directory
set_target_properties(${OUT_BIN_NAME} PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${FusswegDatentools_BINARY_DIR}/bin"
)
# Configure the file into the build directory
configure_file(
"${FusswegDatentools_SOURCE_DIR}/include/config.h.in"
"${FusswegDatentools_BINARY_DIR}/include/config.h"
)
# -----------------------------------------------------------------------------
# Tests
# -----------------------------------------------------------------------------
enable_testing()
add_executable(${TEST_BIN_NAME}
"${FusswegDatentools_SOURCE_DIR}/src/ibox.cpp"
"${FusswegDatentools_SOURCE_DIR}/src/ibox_via.cpp"
"${FusswegDatentools_SOURCE_DIR}/src/crs.cpp"
"${FusswegDatentools_SOURCE_DIR}/src/exif.cpp"
"${FusswegDatentools_SOURCE_DIR}/src/gis.cpp"
"${FusswegDatentools_SOURCE_DIR}/tests/test_main.cpp"
)
add_test(NAME ${TEST_BIN_NAME} COMMAND ${TEST_BIN_NAME})
# -----------------------------------------------------------------------------
# Detect the operating system and architecture
# -----------------------------------------------------------------------------
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND
CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64")
message(STATUS "Building for macOS arm64")
include("./cmake/CMakeLists_osx.cmake")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND
CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
message(STATUS "Building for Linux x86-64")
include("./cmake/CMakeLists_x64.cmake")
else()
message(FATAL_ERROR
"Unsupported operating system or architecture: ${CMAKE_SYSTEM_NAME} ${CMAKE_SYSTEM_PROCESSOR}")
endif()
# Additional common configuration (if any) can be added here