-
Notifications
You must be signed in to change notification settings - Fork 8
/
CMakeLists.txt
95 lines (74 loc) · 3.02 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
## =================================================================== ##
## Copyright (C) 2014-2023 Kimura Ryo ##
## ##
## This Source Code Form is subject to the terms of the Mozilla Public ##
## License, v. 2.0. If a copy of the MPL was not distributed with this ##
## file, You can obtain one at http://mozilla.org/MPL/2.0/. ##
## =================================================================== ##
cmake_minimum_required(VERSION 3.5)
project(libbsdf)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
option(LIBBSDF_ENABLE_FITTING "Enable fitting functions with Ceres Solver" OFF)
set(HEADER_PATH include/libbsdf)
set(SOURCE_PATH src)
# Create groups for each directory and add file paths to the list of source code.
macro(set_sources DIR_NAME)
file(GLOB GROUP_HEADERS "${HEADER_PATH}/${DIR_NAME}/*.h")
file(GLOB GROUP_SOURCES "${SOURCE_PATH}/${DIR_NAME}/*.cpp")
source_group("${DIR_NAME}\\Header Files" FILES ${GROUP_HEADERS})
source_group("${DIR_NAME}\\Source Files" FILES ${GROUP_SOURCES})
list(APPEND SOURCES ${GROUP_HEADERS} ${GROUP_SOURCES})
endmacro()
set(SOURCES)
set_sources(Brdf)
set_sources(Common)
if(LIBBSDF_ENABLE_FITTING)
set_sources(Fitter)
endif()
set_sources(Reader)
set_sources(ReflectanceModel)
set_sources(Writer)
# Set delaunator-cpp.
set(DELAUNATOR_PATH src/ThirdParty/delaunator-cpp)
set(DELAUNATOR_SOURCES "${DELAUNATOR_PATH}/delaunator.hpp" "${DELAUNATOR_PATH}/delaunator.cpp")
source_group("ThirdParty\\delaunator-cpp" FILES ${DELAUNATOR_SOURCES})
list(APPEND SOURCES ${DELAUNATOR_SOURCES})
include_directories(include)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
find_package(Eigen3 REQUIRED)
if(Eigen3_FOUND)
message("Found Eigen-${Eigen3_VERSION}: ${Eigen3_DIR}")
set(EIGEN3_LIB "Eigen3::Eigen")
endif()
if(LIBBSDF_ENABLE_FITTING)
find_package(Ceres REQUIRED)
set(CERES_LIB "Ceres::ceres")
add_definitions(-DLIBBSDF_USE_CERES_SOLVER)
endif()
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
else()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse3")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse3")
endif()
option(LIBBSDF_USE_OPENMP "Use OpenMP" ON)
if(LIBBSDF_USE_OPENMP)
find_package(OpenMP QUIET)
if(OPENMP_FOUND)
message("OpenMP found")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
endif()
endif()
add_library(${PROJECT_NAME} ${SOURCES})
option(LIBBSDF_BUILD_APPLICATIONS "Enable to build libbsdf Applications" ON)
if(LIBBSDF_BUILD_APPLICATIONS)
add_subdirectory(applications)
if(NOT DEFINED LIBBSDF_CORE_FOLDER_NAME)
set(LIBBSDF_CORE_FOLDER_NAME Core)
endif()
set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER ${LIBBSDF_CORE_FOLDER_NAME})
endif()
target_link_libraries(${PROJECT_NAME} Eigen3::Eigen ${CERES_LIB})