-
Notifications
You must be signed in to change notification settings - Fork 61
/
CMakeLists.txt
223 lines (186 loc) · 6.8 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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
PROJECT(sisl)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
# Organize the project in folders (VS only?)
SET_PROPERTY(GLOBAL PROPERTY USE_FOLDERS ON)
# Include directories
INCLUDE_DIRECTORIES(
${sisl_SOURCE_DIR}/include
)
# Make the sisl library
FILE(GLOB sisl_SRCS src/*.c include/*.h)
ADD_LIBRARY(sisl ${sisl_SRCS})
IF(CMAKE_COMPILER_IS_GNUCC)
TARGET_LINK_LIBRARIES(sisl m)
ENDIF(CMAKE_COMPILER_IS_GNUCC)
SET_PROPERTY(TARGET sisl
PROPERTY FOLDER "sisl/Libs")
# This line may be needed only on AMD 64 bit...
#IF(NOT WIN32)
# SET_TARGET_PROPERTIES(sisl PROPERTIES COMPILE_FLAGS "-fPIC")
#ENDIF(NOT WIN32)
# Set various compiler flags
IF(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-unused-but-set-variable -fPIC")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-unused-but-set-variable -fPIC")
ENDIF(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
IF(WIN32)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP8 -D_SCL_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP8 -D_SCL_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS")
ENDIF(WIN32)
# Apps, examples, tests, ...?
option(sisl_COMPILE_APPS "Compile apps?" OFF)
option(sisl_COMPILE_EXAMPLES "Compile examples?" OFF)
option(sisl_COMPILE_VIEWER "Compile viewer?" OFF)
IF(sisl_COMPILE_APPS)
FILE(GLOB sisl_APPS app/*.[cC])
FOREACH(app ${sisl_APPS})
GET_FILENAME_COMPONENT(appname ${app} NAME_WE)
ADD_EXECUTABLE(${appname} ${app})
TARGET_LINK_LIBRARIES(${appname} sisl sisl_streaming)
SET_TARGET_PROPERTIES(${appname}
PROPERTIES RUNTIME_OUTPUT_DIRECTORY app)
ENDFOREACH(app)
ENDIF()
IF(sisl_COMPILE_EXAMPLES OR sisl_COMPILE_VIEWER OR sisl_COMPILE_APPS)
INCLUDE_DIRECTORIES(
${sisl_SOURCE_DIR}/streaming/include
)
FILE(GLOB sisl_go_SRCS streaming/src/*.cpp streaming/include/*.h)
ADD_LIBRARY(sisl_streaming ${sisl_go_SRCS})
# IF(CMAKE_COMPILER_IS_GNUCC)
# TARGET_LINK_LIBRARIES(sisl_go m)
# ENDIF(CMAKE_COMPILER_IS_GNUCC)
ENDIF()
IF(sisl_COMPILE_EXAMPLES)
FILE(GLOB sisl_APPS2 examples/*.cpp)
FOREACH(app ${sisl_APPS2})
GET_FILENAME_COMPONENT(appname ${app} NAME_WE)
ADD_EXECUTABLE(${appname} ${app})
TARGET_LINK_LIBRARIES(${appname} sisl sisl_streaming)
SET_TARGET_PROPERTIES(${appname}
PROPERTIES RUNTIME_OUTPUT_DIRECTORY examples)
ENDFOREACH(app)
ENDIF()
IF(sisl_COMPILE_VIEWER)
find_package(OpenGL REQUIRED)
find_path(OPENGL_INCLUDE_DIR
gl.h
PATH_PREFIXES GL
PATHS
/usr/local/include
/usr/include
"$ENV{HOME}\\Install\\include" # For some reason HOME is not found in VS 2019.
"C:\\Users\\$ENV{USERNAME}\\Install\\include"
"C:\\local\\include"
)
if(WIN32)
find_path(GLUT_INCLUDE_DIR
glut.h
PATH_PREFIXES GL
PATHS
"$ENV{PROGRAMW6432}/Microsoft SDKs/Windows/v6.0A/Include"
"$ENV{HOME}\\Install\\include" # For some reason HOME is not found in VS 2019.
"C:\\Users\\$ENV{USERNAME}\\Install\\include"
"C:\\local\\include"
)
if(${MSVC_VERSION} EQUAL 1900)
set(MSVC_NAME "msvc2015_")
# MESSAGE("Visual Studio 2015!")
elseif((${MSVC_VERSION} GREATER_EQUAL 1920) AND (${MSVC_VERSION} LESS 1930))
# MESSAGE("Visual Studio 2019!")
set(MSVC_NAME "msvc2019_")
elseif((${MSVC_VERSION} GREATER_EQUAL 1930) AND (${MSVC_VERSION} LESS 1950))
set(MSVC_NAME "msvc2022_")
else()
message("MSVC version not supported or not installed!")
endif()
if(CMAKE_CL_64)
set(WIN_LIB_TYPE "64")
else()
set(WIN_LIB_TYPE "32")
endif()
find_library( GLUT_LIBRARY_RELEASE NAMES freeglut
PATHS
"~/Install/${MSVC_NAME}lib${WIN_LIB_TYPE}/Release"
"C:/local/${MSVC_NAME}lib${WIN_LIB_TYPE}/Release"
${GLUT_ROOT_PATH}/Release
#"~/Install/${MSVC_NAME}lib${WIN_LIB_TYPE}/Release"
)
find_library( GLUT_LIBRARY_DEBUG NAMES freeglutd
PATHS
${GLUT_ROOT_PATH}/Debug
"~/Install/${MSVC_NAME}lib${WIN_LIB_TYPE}/Debug"
"C:/local/${MSVC_NAME}lib${WIN_LIB_TYPE}/Debug"
#"~/Install/${MSVC_NAME}lib${WIN_LIB_TYPE}/Debug"
)
# message("GLUT_LIBRARY_RELEASE: ${GLUT_LIBRARY_RELEASE}")
# message("GLUT_LIBRARY_DEBUG: ${GLUT_LIBRARY_DEBUG}")
set(GLUT_glut_LIBRARY "")
# message("GLUT_glut_LIBRARY: ${GLUT_glut_LIBRARY}")
if(GLUT_LIBRARY_DEBUG)
set(GLUT_glut_LIBRARY ${GLUT_glut_LIBRARY} debug ${GLUT_LIBRARY_DEBUG})
endif()
if(GLUT_LIBRARY_RELEASE)
set(GLUT_glut_LIBRARY ${GLUT_glut_LIBRARY} optimized ${GLUT_LIBRARY_RELEASE})
endif()
# message("GLUT_glut_LIBRARY: ${GLUT_glut_LIBRARY}")
else()
find_package(GLUT REQUIRED)
endif()
INCLUDE_DIRECTORIES(
${sisl_SOURCE_DIR}/viewer/include
${OPENGL_INCLUDE_DIR}
${GLUT_INCLUDE_DIR}
)
# message("GLUT_INCLUDE_DIR: ${GLUT_INCLUDE_DIR}")
# message("GLUT_INCLUDE_PATH: ${GLUT_INCLUDE_PATH}")
# message("GLUT_glut_LIBRARY_RELEASE: ${GLUT_glut_LIBRARY_RELEASE}")
# message("GLUT_glut_LIBRARY_DEBUG: ${GLUT_glut_LIBRARY_DEBUG}")
# message("GLUT_glut_LIBRARY: ${GLUT_glut_LIBRARY}")
# message("OPENGL_LIBRARIES: ${OPENGL_LIBRARIES}")
# message("MSVC_NAME lib WIN_LIB_TYPE: ${MSVC_NAME}lib${WIN_LIB_TYPE}")
FILE(GLOB sisl_viewer_SRCS viewer/src/*.cpp viewer/include/*.h)
ADD_LIBRARY(sisl_viewer ${sisl_viewer_SRCS})
IF(CMAKE_COMPILER_IS_GNUCC)
TARGET_LINK_LIBRARIES(sisl_streaming sisl)
ENDIF(CMAKE_COMPILER_IS_GNUCC)
FILE(GLOB sisl_APPS3 viewer/*.cpp)
FOREACH(app ${sisl_APPS3})
GET_FILENAME_COMPONENT(appname ${app} NAME_WE)
ADD_EXECUTABLE(${appname} ${app})
TARGET_LINK_LIBRARIES(${appname} sisl sisl_streaming sisl_viewer ${OPENGL_LIBRARIES} ${GLUT_glut_LIBRARY})
SET_TARGET_PROPERTIES(${appname}
PROPERTIES RUNTIME_OUTPUT_DIRECTORY viewer)
ENDFOREACH(app)
ENDIF()
# 'install' target
IF(WIN32)
# Windows
SET(CMAKE_INSTALL_PREFIX CACHE INTERNAL "")
SET(sisl_INSTALL_PREFIX "$ENV{PROGRAMFILES}/SINTEF/sisl"
CACHE PATH "Path to install SISL")
INSTALL(TARGETS sisl DESTINATION ${sisl_INSTALL_PREFIX}/lib)
INSTALL(DIRECTORY include/
DESTINATION ${sisl_INSTALL_PREFIX}/include
FILES_MATCHING PATTERN "*.h"
PATTERN ".svn" EXCLUDE
)
ELSE(WIN32)
# Linux
# lib
INSTALL(TARGETS sisl DESTINATION lib COMPONENT sisl)
# include
INSTALL(DIRECTORY include/
COMPONENT sisl-dev
DESTINATION include
FILES_MATCHING PATTERN "*.h"
PATTERN ".svn" EXCLUDE
)
ENDIF(WIN32)
# CPack stuff
IF(NOT GoTools_ALL_COMPILE)
SET(CPACK_SOURCE_PACKAGE_FILE_NAME "sisl-4.6.0")
SET(CPACK_SOURCE_IGNORE_FILES "/CVS/;/\\.svn/;\\.swp$;\\.#;/#;.*~")
INCLUDE(CPack)
ENDIF(NOT GoTools_ALL_COMPILE)
SET(CPACK_STRIP_FILES ${CPACK_STRIP_FILES} libsisl.so)