-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathCMakeLists.txt
108 lines (88 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
cmake_minimum_required(VERSION 3.1)
project(SDFilter)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_VERBOSE_MAKEFILE ON)
# Additional compiler flags
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
message("Clang compiler found.")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -march=native -mtune=native")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
message("AppleClang compiler found.")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -march=native -mtune=native")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
message("GNU compiler found.")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -march=native -mtune=native")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
message("MSVC compiler found.")
add_definitions(/DUSE_MSVC)
add_definitions(/D_USE_MATH_DEFINES)
endif()
# Detect OpenMP environment
set(OPENMP ON CACHE BOOL "OpenMP")
if(OPENMP)
find_package(OpenMP QUIET)
if(OPENMP_FOUND)
message("OpenMP found. OpenMP activated in release.")
add_definitions(-DUSE_OPENMP)
else()
message("OpenMP not found.")
endif()
endif()
# Detect Eigen3
if(NOT EIGEN3_FOUND)
find_package(Eigen3 REQUIRED)
if(EIGEN3_FOUND)
message("Found external Eigen. include: ${EIGEN3_INCLUDE_DIR}, version: ${EIGEN3_VERSION_STRING}.")
endif()
endif()
# OpenMesh library
set(OPENMESH_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/external/OpenMesh")
file(GLOB_RECURSE OPENMESH_HEADERS "${OPENMESH_SOURCE_DIR}/Core/*.hh" "${OPENMESH_SOURCE_DIR}/Core/*.h" "${OPENMESH_SOURCE_DIR}/Tools/*.hh" "${OPENMESH_SOURCE_DIR}/Tools/*.h")
file(GLOB_RECURSE OPENMESH_SOURCES "${OPENMESH_SOURCE_DIR}/Core/*.cc" "${OPENMESH_SOURCE_DIR}/Tools/*.cc")
add_library(OpenMesh STATIC ${OPENMESH_HEADERS} ${OPENMESH_SOURCES})
target_include_directories(OpenMesh PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/external")
target_compile_definitions(OpenMesh PUBLIC OM_STATIC_BUILD)
add_library(MeshSDLibrary INTERFACE)
target_include_directories(MeshSDLibrary INTERFACE
${CMAKE_CURRENT_SOURCE_DIR}
)
target_link_libraries(MeshSDLibrary
INTERFACE
OpenMesh
Eigen3::Eigen
)
# Executable for filtering
add_executable(MeshSDFilter
EigenTypes.h
MeshTypes.h
SDFilter.h
MeshNormalFilter.h
MeshSDFilter.cpp
)
target_link_libraries(MeshSDFilter MeshSDLibrary)
# Executable for denoising
add_executable(MeshDenoiser
EigenTypes.h
MeshTypes.h
SDFilter.h
MeshNormalFilter.h
MeshNormalDenoising.h
MeshDenoiser.cpp
)
target_link_libraries(MeshDenoiser MeshSDLibrary)
if(OPENMP_FOUND)
#target_compile_options(MeshSDLibrary PUBLIC "$<$<CONFIG:RELEASE>:${OpenMP_CXX_FLAGS}>")
#target_compile_definitions(MeshSDLibrary PUBLIC "$<$<CONFIG:RELEASE>:USE_OPENMP>")
#target_link_libraries(MeshSDLibrary "$<$<CONFIG:RELEASE>:${OpenMP_CXX_FLAGS}>")
target_compile_options(MeshSDFilter PUBLIC "$<$<CONFIG:RELEASE>:${OpenMP_CXX_FLAGS}>")
target_compile_definitions(MeshSDFilter PUBLIC "$<$<CONFIG:RELEASE>:USE_OPENMP>")
target_link_libraries(MeshSDFilter "$<$<CONFIG:RELEASE>:${OpenMP_CXX_FLAGS}>")
target_compile_options(MeshDenoiser PUBLIC "$<$<CONFIG:RELEASE>:${OpenMP_CXX_FLAGS}>")
target_compile_definitions(MeshDenoiser PUBLIC "$<$<CONFIG:RELEASE>:USE_OPENMP>")
target_link_libraries(MeshDenoiser "$<$<CONFIG:RELEASE>:${OpenMP_CXX_FLAGS}>")
endif()