-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
192 lines (148 loc) · 6.22 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
cmake_minimum_required(VERSION 3.16)
project(robotic-mm-optimization)
list(PREPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
set(SRC_ROOT_PATH "${CMAKE_CURRENT_SOURCE_DIR}/src/")
set(DEPENDENCIES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/")
###################################
######## configure PROJECT ########
###################################
# set c++17
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
add_compile_options(-Wall -Wextra -Wuninitialized -pedantic-errors -Wno-unused-parameter)
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
add_compile_options(-Wc++20-extensions)
endif()
set(CMAKE_CXX_EXTENSIONS OFF)
########################################
######## configure DEPENDENCIES ########
########################################
# libigl settings
# make compilation faster using static linking
option(LIBIGL_USE_STATIC_LIBRARY "Use libigl as static library" OFF)
option(LIBIGL_WITH_ANTTWEAKBAR "Use AntTweakBar" OFF)
option(LIBIGL_WITH_CGAL "Use CGAL" OFF)
option(LIBIGL_WITH_COMISO "Use CoMiso" OFF)
option(LIBIGL_WITH_CORK "Use Cork" OFF)
option(LIBIGL_WITH_EMBREE "Use Embree" OFF)
option(LIBIGL_WITH_LIM "Use LIM" OFF)
option(LIBIGL_WITH_MATLAB "Use Matlab" OFF)
option(LIBIGL_WITH_MOSEK "Use MOSEK" OFF)
option(LIBIGL_WITH_OPENGL "Use OpenGL" ON)
option(LIBIGL_WITH_OPENGL_GLFW "Use GLFW" ON)
option(LIBIGL_WITH_OPENGL_GLFW_IMGUI "Use ImGui" ON)
option(LIBIGL_WITH_PNG "Use PNG" OFF)
option(LIBIGL_WITH_PYTHON "Use Python" OFF)
option(LIBIGL_WITH_TETGEN "Use Tetgen" OFF)
option(LIBIGL_WITH_TRIANGLE "Use Triangle" OFF)
option(LIBIGL_WITH_VIEWER "Use OpenGL viewer" ON)
option(LIBIGL_WITH_XML "Use XML" ON)
# Include libigl
set(LIBIGL_DIR "${DEPENDENCIES_DIR}/libigl/")
set(LIBIGL_INCLUDE_DIR "${LIBIGL_DIR}/include/")
list(APPEND CMAKE_MODULE_PATH "${LIBIGL_INCLUDE_DIR}/../cmake")
include(libigl)
# Include cppOpt
include_directories("${DEPENDENCIES_DIR}/cppOpt/inc")
# Include & link Ipopt lib
# message("before set IPOPT_DIR = ${IPOPT_DIR}")
# set(IPOPT_DIR CACHE PATH "Ipopt top-level directory")
# message("after set IPOPT_DIR = ${IPOPT_DIR}")
# if(NOT ${IPOPT_DIR})
# message("IPOPT_DIR is not set")
# endif()
if(WIN32)
include_directories("${DEPENDENCIES_DIR}/Ipopt/include/coin-or")
set(IPOPT_DIR "${DEPENDENCIES_DIR}/Ipopt/libWIN" CACHE PATH "directory where Ipopt lib is found")
link_directories("${IPOPT_DIR}/lib")
link_libraries("ipopt.dll.lib")
# find_library(IPOPT_LIB
# "ipopt"
# PATHS "${IPOPT_DIR}" "${IPOPT_DIR}/lib" "${DEPENDENCIES_DIR}/Ipopt/libWIN/lib"
# )
# message("after find_library IPOPT_LIB = ${IPOPT_LIB}")
# if (${IPOPT_LIB} MATCHES "NOTFOUND")
# message("ERROR: Could not find Ipopt lib for Windows.")
# else()
# get_filename_component(IPOPT_LIB_FILE "${IPOPT_LIB}" NAME)
# link_libraries(${IPOPT_LIB_FILE})
# message("Found Ipopt library for Windows named ${IPOPT_LIB_FILE}")
# get_filename_component(IPOPT_LIB_PATH "${IPOPT_LIB}" DIRECTORY)
# link_directories(${IPOPT_LIB_PATH})
# message("Found Ipopt library for Windows at ${IPOPT_LIB_PATH}")
# set(IPOPT_DIR "${IPOPT_LIB_PATH}/../")
# message("IPOPT_DIR = ${IPOPT_DIR}")
# find_file(IPOPT_INC "*.h*" PATHS "${IPOPT_DIR}" "${DEPENDENCIES_DIR}/Ipopt/include/coin-or")
# message("IPOPT_INC = ${IPOPT_INC}")
# include_directories("${DEPENDENCIES_DIR}/Ipopt/include/coin-or")
# endif()
elseif(APPLE)
message("TODO implement finding Ipopt on MACOSX")
message("Please run cmake again and specify the top-level directory of your Ipopt impmenentation:\n
'make ../ -DIPOPT_DIR:PATH=<path/to/your/Ipopt>'")
endif()
#################################
######## include SOURCES ########
#################################
include_directories(${SRC_ROOT_PATH})
# Add header files recursively
file(
GLOB_RECURSE HEADER_FILES
LIST_DIRECTORIES false
"${SRC_ROOT_PATH}/*.h*"
)
# Add source files recursively
file(
GLOB_RECURSE SRC_FILES
LIST_DIRECTORIES false
"${SRC_ROOT_PATH}/*.c*"
"${SRC_ROOT_PATH}/*.h*"
)
# # Add source files recursively
# file(
# GLOB_RECURSE COMMON_SRC_FILES
# LIST_DIRECTORIES false
# "${SRC_ROOT_PATH}/*.c*"
# "${SRC_ROOT_PATH}/*.h*"
# )
# file(
# GLOB EXECUTABLE_SRC_FILES
# LIST_DIRECTORIES false
# "${SRC_ROOT_PATH}/bin/*.c*"
# )
# message(${COMMON_SRC_FILES})
# message(${EXECUTABLE_SRC_FILES})
# list(REMOVE_ITEM COMMON_SRC_FILES ${EXECUTABLE_SRC_FILES})
# message(${COMMON_SRC_FILES})
# message(${EXECUTABLE_SRC_FILES})
# Group source files for IDE (Visual Studio) -- remove this if it causes problems for other IDEs
foreach(SRC_FILE IN ITEMS ${SRC_FILES})
get_filename_component(SRC_FILE_PATH "${SRC_FILE}" PATH)
file(RELATIVE_PATH SRC_PATH_RELATIVE "${SRC_ROOT_PATH}" "${SRC_FILE_PATH}")
string(REPLACE "/" "\\" GROUP_PATH "${SRC_PATH_RELATIVE}")
source_group("${GROUP_PATH}" FILES "${SRC_FILE}")
endforeach()
if(WIN32)
add_definitions (-D_USE_MATH_DEFINES)
message(" use -D_USE_MATH_DEFINES on windows")
endif()
link_libraries(igl::core igl::opengl igl::opengl_glfw igl::opengl_glfw_imgui igl::xml)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
link_libraries(stdc++fs)
endif()
add_executable(${PROJECT_NAME} ${SRC_FILES})
# WIN: post-build event to copy Ipopt dlls to target directory
if(WIN32)
message("post build IPOPT_DIR = ${IPOPT_DIR}")
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
"${IPOPT_DIR}/bin"
$<TARGET_FILE_DIR:${PROJECT_NAME}>)
endif()
# # Add your project files
# file(GLOB SRC_FILES *.cpp)
# add_executable(${PROJECT_NAME} ${SRC_FILES})
# target_link_libraries(${PROJECT_NAME} PUBLIC igl::core igl::opengl_glfw)
# target_compile_features(example PRIVATE cxx_std_17)