-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathCMakeLists.txt
97 lines (64 loc) · 3 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 lists for the GeometronLib - (26/07/2015) ===
cmake_minimum_required(VERSION 3.5)
project(GeometronLib)
# === Build path ===
set(OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/build)
set(EXECUTABLE_OUTPUT_PATH ${OUTPUT_DIR} CACHE PATH "Build directory" FORCE)
set(LIBRARY_OUTPUT_PATH ${OUTPUT_DIR} CACHE PATH "Build directory" FORCE)
set(PROJECT_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/include")
set(PROJECT_TEST_DIR "${PROJECT_SOURCE_DIR}/test")
# === Preprocessor definitions ===
macro(ADD_TEST_PROJECT TEST_NAME TEST_FILES)
add_executable(${TEST_NAME} ${TEST_FILES})
target_link_libraries(${TEST_NAME} ${OPENGL_LIBRARIES} ${GLUT_LIBRARIES} geomlib)
set_target_properties(${TEST_NAME} PROPERTIES LINKER_LANGUAGE CXX DEBUG_POSTFIX "D")
target_compile_features(${TEST_NAME} PRIVATE cxx_range_for)
endmacro()
macro(ADD_DEFINE IDENT)
if(MSVC)
add_definitions("/D${IDENT}")
else()
add_definitions("-D${IDENT}")
endif()
endmacro()
# === Global files ===
file(GLOB_RECURSE HeadersAll "${PROJECT_SOURCE_DIR}/include/*.*")
file(GLOB_RECURSE SourcesAll "${PROJECT_SOURCE_DIR}/sources/*.*")
set(FilesAll ${HeadersAll} ${SourcesAll})
# === Options ===
option(GeomLib_DEFAULT_PLANE_EQUATION_ALT "Enables the alternative plane euqation as default (i.e. 'n*x + d = 0' instead of 'n*x = d')" OFF)
option(GeomLib_ENABLE_MULTI_THREADING "Enables multi-threading for a couple of functions (currently only for VisualC++)" ON)
if(GeomLib_ENABLE_MULTI_THREADING)
ADD_DEFINE(GM_ENABLE_MULTI_THREADING)
endif()
if(GeomLib_DEFAULT_PLANE_EQUATION_ALT)
ADD_DEFINE(GM_DEFAULT_PLANE_EQUATION_ALT)
endif()
# === Include directories ===
include_directories("${PROJECT_INCLUDE_DIR}")
include(cmake/FindGaussianLib.cmake)
# === Source groups ===
source_group("Include" FILES ${HeadersAll})
source_group("Sources" FILES ${SourcesAll})
# === Binaries ===
add_library(geomlib STATIC ${FilesAll})
set_target_properties(geomlib PROPERTIES LINKER_LANGUAGE CXX DEBUG_POSTFIX "D")
target_compile_features(geomlib PRIVATE cxx_strong_enums cxx_auto_type)
add_executable(Test1_Primitives "${PROJECT_TEST_DIR}/Test1_Primitives.cpp")
set_target_properties(Test1_Primitives PROPERTIES LINKER_LANGUAGE CXX DEBUG_POSTFIX "D")
target_compile_features(Test1_Primitives PRIVATE cxx_strong_enums cxx_auto_type)
target_link_libraries(Test1_Primitives geomlib)
find_package(OpenGL)
find_package(GLUT)
if(OpenGL_FOUND AND GLUT_FOUND)
include_directories(${GLUT_INCLUDE_DIR})
ADD_TEST_PROJECT(Test2_Mesh "${PROJECT_TEST_DIR}/Test2_Mesh.cpp")
ADD_TEST_PROJECT(Test3_MeshGen "${PROJECT_TEST_DIR}/Test3_MeshGen.cpp")
ADD_TEST_PROJECT(Test4_Anim "${PROJECT_TEST_DIR}/Test4_Anim.cpp")
ADD_TEST_PROJECT(Test5_Skeleton "${PROJECT_TEST_DIR}/Test5_Skeleton.cpp")
ADD_TEST_PROJECT(Test6_Collision "${PROJECT_TEST_DIR}/Test6_Collision.cpp")
ADD_TEST_PROJECT(Test7_RayCast "${PROJECT_TEST_DIR}/Test7_RayCast.cpp")
ADD_TEST_PROJECT(Test8_Vectorization "${PROJECT_TEST_DIR}/Test8_Vectorization.cpp")
else()
message("OpenGL and GLUT missing -> Optional tests excluded from project")
endif()