-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
120 lines (100 loc) · 3.11 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
cmake_minimum_required(VERSION 3.10)
set(CMAKE_TOOLCHAIN_FILE "${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake")
project(WPIcal)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
enable_testing()
include(cmake/modules/GenResources.cmake)
generate_resources(src/main/resources generated/main/cpp OV ov outlineviewer_resources_src)
if(WIN32)
set(outlineviewer_rc src/win/outlineviewer.rc)
elseif(APPLE)
set(MACOSX_BUNDLE_ICON_FILE ov.icns)
set(APP_ICON_MACOSX src/mac/ov.icns)
set_source_files_properties(${APP_ICON_MACOSX} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
endif()
# Add include directories for the project
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/include)
# Add subdirectories for external libraries
add_subdirectory(wpigui)
add_subdirectory(imgui)
add_subdirectory(mrcal-java)
# Find required packages
find_package(apriltag REQUIRED)
find_package(Eigen3 CONFIG REQUIRED)
find_package(Ceres CONFIG REQUIRED)
find_package(nlohmann_json CONFIG REQUIRED)
find_package(OpenCV REQUIRED)
find_package(suitesparse REQUIRED)
find_package(GTest REQUIRED)
# Add the executable and specify the source files
add_executable(${PROJECT_NAME}
src/main/cpp/WPIcal.cpp
src/main/cpp/fieldcalibration.cpp
src/main/cpp/cameracalibration.cpp
src/main/cpp/fieldmap.cpp
src/main/cpp/fmap.cpp
src/main/cpp/tagpose.cpp
${outlineviewer_resources_src}
${outlineviewer_rc}
)
# Include directories
target_include_directories(${PROJECT_NAME} PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/src/main/include
${CMAKE_CURRENT_SOURCE_DIR}/build/vcpkg_installed/x64-windows/include
${CMAKE_CURRENT_SOURCE_DIR}/mrcal-java/src
)
# Link the libraries
target_link_libraries(${PROJECT_NAME} PRIVATE
wpigui
imgui
mrcal_jni
apriltag::apriltag
Eigen3::Eigen
Ceres::ceres
nlohmann_json::nlohmann_json
SuiteSparse::amd
SuiteSparse::cholmod
${OpenCV_LIBS}
)
add_executable(
tests
src/main/cpp/fieldcalibration.cpp
src/main/cpp/cameracalibration.cpp
src/main/cpp/fieldmap.cpp
src/main/cpp/fmap.cpp
src/main/cpp/tagpose.cpp
src/test/test.cpp
)
target_include_directories(tests PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/src/main/include
${CMAKE_CURRENT_SOURCE_DIR}/build/vcpkg_installed/x64-windows/include
${CMAKE_CURRENT_SOURCE_DIR}/mrcal-java/src
)
target_link_libraries(tests PRIVATE
wpigui
imgui
mrcal_jni
apriltag::apriltag
Eigen3::Eigen
Ceres::ceres
nlohmann_json::nlohmann_json
SuiteSparse::amd
SuiteSparse::cholmod
${OpenCV_LIBS}
GTest::GTest
)
if(WIN32)
set_target_properties(${PROJECT_NAME} PROPERTIES WIN32_EXECUTABLE YES)
elseif(APPLE)
set_target_properties(${PROJECT_NAME} PROPERTIES MACOSX_BUNDLE YES OUTPUT_NAME "WPIcal")
endif()
include(GoogleTest)
gtest_discover_tests(tests)
add_custom_command(TARGET tests
POST_BUILD
COMMAND ctest --output-on-failure
DEPENDS ${PROJECT_NAME})
add_dependencies(tests ${PROJECT_NAME})
target_compile_definitions(tests PRIVATE PROJECT_ROOT_PATH="${CMAKE_SOURCE_DIR}")