CMakeLists.txt 8.13 KB
Newer Older
1
cmake_minimum_required(VERSION 2.8)
Pierre Kraemer's avatar
Pierre Kraemer committed
2

3
# Thanks to Etienne Schmitt for CMakeLists modifications
Pierre Kraemer's avatar
Pierre Kraemer committed
4

5
project(CGoGN)
untereiner's avatar
untereiner committed
6

7
SET ( CGoGN_ROOT_DIR ${CMAKE_SOURCE_DIR} )
8
SET ( CGoGN_SRC_DIR ${CMAKE_SOURCE_DIR}/CGoGN)
9
SET ( CMAKE_MODULE_PATH ${CGoGN_ROOT_DIR}/cmake_modules/ )
Sylvain Thery's avatar
Sylvain Thery committed
10

11
INCLUDE(${CGoGN_ROOT_DIR}/cmake_modules/functions.cmake)
Sylvain Thery's avatar
Sylvain Thery committed
12

13 14


15 16 17
#
# Available options
#
18 19 20
SET ( CGoGN_WITH_ASSIMP OFF CACHE BOOL "build CGoGN with Assimp" )
SET ( CGoGN_WITH_ZINRI OFF CACHE BOOL "build CGoGN with Zinri lib" )
SET ( CGoGN_WITH_QT ON CACHE BOOL "build CGoGN with Qt lib" )
Sylvain Thery's avatar
Sylvain Thery committed
21
SET ( CGoGN_DESIRED_QT_VERSION "4" CACHE STRING "4: QT4/5" )
Sylvain Thery's avatar
Sylvain Thery committed
22
SET ( CGoGN_WITH_GLEWMX OFF CACHE BOOL "use multi-contex GLEW (for VRJuggler)" )
23 24 25 26 27 28 29 30 31
SET ( CGoGN_USE_OGL_CORE_PROFILE OFF CACHE BOOL "use OpenGL 3.3 core profile (do not work on mac)" )

SET ( CGoGN_COMPILE_EXAMPLES OFF CACHE BOOL "compile examples" )
SET ( CGoGN_COMPILE_TUTOS OFF CACHE BOOL "compile tutorials" )
SET ( CGoGN_COMPILE_TESTS OFF CACHE BOOL "compile tests" )
SET ( CGoGN_COMPILE_BENCHES OFF CACHE BOOL "compile benches" )
SET ( CGoGN_COMPILE_SANDBOX OFF CACHE BOOL "compile all in sandbox" )
SET ( CGoGN_ASSERT_ACTIVED OFF CACHE BOOL "assertion activated")
SET ( CGoGN_ONELIB OFF CACHE BOOL "build CGoGN in one lib" )
32 33 34
IF (WIN32)
	SET ( CMAKE_CONFIGURATION_TYPES Release Debug)
	SET ( CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING "Only Release or Debug" FORCE)
Sylvain Thery's avatar
Sylvain Thery committed
35
	SET ( CGoGN_WITH_QTCREATOR OFF CACHE BOOL "use QtCreator to compile (Experimental" )
36
ENDIF ()
Sylvain Thery's avatar
Sylvain Thery committed
37
SET ( BUILD_SHARED_LIBS ON CACHE BOOL "if used all library are build as shared type (.so/.dylib/.dll)" )
38

39 40 41 42 43 44

checkCpp11Support()
setBuildType()


SET(EXECUTABLE_OUTPUT_PATH ${CGoGN_ROOT_DIR}/bin/)
45
IF(WIN32)
Sylvain Thery's avatar
Sylvain Thery committed
46
	IF (CGoGN_WITH_QTCREATOR)
47
		SET(LIBRARY_OUTPUT_PATH ${CGoGN_ROOT_DIR}/bin/${CMAKE_BUILD_TYPE})
Sylvain Thery's avatar
Sylvain Thery committed
48 49
	ELSE()
		SET(LIBRARY_OUTPUT_PATH ${CGoGN_ROOT_DIR}/bin/)
50
	ENDIF()
51 52
ELSE()
	SET(LIBRARY_OUTPUT_PATH ${CGoGN_ROOT_DIR}/lib/${CMAKE_BUILD_TYPE})
Sylvain Thery's avatar
Sylvain Thery committed
53 54
ENDIF()

55 56 57
#
# External Libraries (not included a third party libraries)
#
Sylvain Thery's avatar
Sylvain Thery committed
58 59 60 61
IF(WIN32)
	SET ( CMAKE_PREFIX_PATH ${CGoGN_ROOT_DIR}/windows_dependencies CACHE STRING "path to dependencies" )
ENDIF(WIN32)

62 63 64
FIND_PACKAGE(OpenGL REQUIRED)
FIND_PACKAGE(ZLIB REQUIRED)
FIND_PACKAGE(GLEW REQUIRED)
65
IF (CGoGN_WITH_QT)
Sylvain Thery's avatar
Sylvain Thery committed
66 67 68 69 70
	IF(${CGoGN_DESIRED_QT_VERSION} STREQUAL "5")
		include(cmake_modules/Qt_5x.cmake)
	ELSE()
		include(cmake_modules/Qt_4x.cmake)
	ENDIF()
71
ELSE ()
72
	FIND_PACKAGE(DevIL REQUIRED)
73
ENDIF()
Sylvain Thery's avatar
Sylvain Thery committed
74 75

IF (WIN32)
76 77
	set(SUITESPARSE_SUITESPARSECONFIG_INCLUDE_DIR  ${CGoGN_ROOT_DIR}/windows_dependencies/include)
	set(SUITESPARSE_USE_LAPACK_BLAS ON)
78
ENDIF()
Sylvain Thery's avatar
Sylvain Thery committed
79
FIND_PACKAGE(SuiteSparse REQUIRED)
Sylvain Thery's avatar
Sylvain Thery committed
80

81 82 83
#
#	ThirdParty
#
84

85
INCLUDE_DIRECTORIES(${CGoGN_ROOT_DIR}/ThirdParty/include)
Sylvain Thery's avatar
Sylvain Thery committed
86

87 88 89 90 91 92
ADD_SUBDIRECTORY(ThirdParty/Tools)

ADD_SUBDIRECTORY(ThirdParty/OpenNL)

ADD_SUBDIRECTORY(ThirdParty/tetgen)

93
IF (CGoGN_WITH_ZINRI)
94
	ADD_SUBDIRECTORY(ThirdParty/Zinri)
95
ENDIF()
96

97
IF (CGoGN_WITH_ASSIMP)
98
	ADD_SUBDIRECTORY(ThirdParty/Assimp)
99
ENDIF ()
Sylvain Thery's avatar
Sylvain Thery committed
100

101 102
ADD_SUBDIRECTORY(ThirdParty/TinyXml2)

103 104
#IF (CGoGN_WITH_QT AND (NOT WIN32))
IF (CGoGN_WITH_QT)
105 106
	ADD_SUBDIRECTORY(ThirdParty/libQGLViewer/QGLViewer)
ENDIF()
Sylvain Thery's avatar
Sylvain Thery committed
107

108 109 110
IF (NOT WIN32)
	ADD_SUBDIRECTORY(ThirdParty/libuuid)
ENDIF()
Sylvain Thery's avatar
Sylvain Thery committed
111 112


113

114 115 116 117 118 119 120 121 122 123 124
#
# COMPILER FLAGS
#
IF(NOT WIN32)
	SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -fPIC -std=c++11")
	SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Woverride-init -fPIC")
	# remove the 60000+ "no unused local typedefs" warnings with GCC4.8+
	IF(CMAKE_COMPILER_IS_GNUCXX)
		SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-local-typedefs")
		SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-local-typedefs")
	ENDIF()
125 126 127
	IF(APPLE)
		set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated -Wno-overloaded-virtual")
	ENDIF()
Sylvain Thery's avatar
Sylvain Thery committed
128
ELSE()
Sylvain Thery's avatar
Sylvain Thery committed
129
	ADD_DEFINITIONS("/wd4251") #dll export warnings
130 131
ENDIF()

132

133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149


#
# COMPILE DEFINITIONS
#
LIST(APPEND CGoGN_DEFS -DGLM_FORCE_RADIANS)

LIST(APPEND CGoGN_DEFS -DCGOGN_ASSERT_BOOL=${CGoGN_ASSERT_ACTIVED})

IF(CGoGN_USE_OGL_CORE_PROFILE)
	LIST(APPEND CGoGN_DEFS -DCGoGN_USE_OGL_CORE_PROFILE=1)
ENDIF()

LIST(APPEND CGoGN_DEFS -DSHADERPATH=\"${CGoGN_ROOT_DIR}/lib/Shaders/\")

IF (CGoGN_WITH_ASSIMP)
	LIST(APPEND CGoGN_DEFS -DCGOGN_WITH_ASSIMP)
150
ENDIF ()
151

152 153
IF (CGoGN_WITH_ZINRI)
	LIST(APPEND CGoGN_DEFS -DCGOGN_WITH_ZINRI)
154
ENDIF ()
155

156 157
IF (CGoGN_WITH_GLEWMX)
	LIST(APPEND CGoGN_DEFS -DCGOGN_GLEW_MX)
158 159
ENDIF ()

160 161
IF (CGoGN_WITH_QT)
	LIST(APPEND CGoGN_DEFS -DCGOGN_WITH_QT)
Sylvain Thery's avatar
Sylvain Thery committed
162
#	LIST(APPEND CGoGN_DEFS("-DCGOGN_QT_DESIRED_VERSION=${CGoGN_DESIRED_QT_VERSION}"))
163 164
ENDIF()

165 166 167 168
IF(WIN32)
	LIST(APPEND CGoGN_DEFS -D_USE_MATH_DEFINES)
ENDIF ()

169 170 171
ADD_DEFINITIONS(${CGoGN_DEFS})


172

173 174 175 176 177
#
# INCLUDES AND LIBS
#
SET (CGoGN_EXT_INCLUDES)
SET (CGoGN_EXT_LIBS)
178
IF (CGoGN_WITH_QT)
179 180
        LIST(APPEND CGoGN_EXT_INCLUDES ${QT_INCLUDE_DIR})
        LIST(APPEND CGoGN_EXT_LIBS QGLViewer ${QT_LIBRARIES})
Sylvain Thery's avatar
Sylvain Thery committed
181
		LIST(APPEND CGoGN_EXT_INCLUDES ${CGoGN_ROOT_DIR}/ThirdParty/libQGLViewer/)
182
ELSE ()
183 184
	 LIST(APPEND CGoGN_EXT_INCLUDES ${IL_INCLUDE_DIR})
	 LIST(APPEND CGoGN_EXT_LIBS ${IL_LIBRARIES})
185
ENDIF ()
186

Sylvain Thery's avatar
Sylvain Thery committed
187
# define includes of external libs 
188 189
LIST(INSERT CGoGN_EXT_INCLUDES 0
    ${CGoGN_ROOT_DIR}/ThirdParty/include
Sylvain Thery's avatar
Sylvain Thery committed
190 191 192
	${OPENGL_INCLUDE_DIR}
	${GLEW_INCLUDE_DIRS}
	${ZLIB_INCLUDE_DIRS}
193
	${SUITESPARSE_INCLUDE_DIRS}
194
)
Sylvain Thery's avatar
Sylvain Thery committed
195

196 197 198 199 200 201 202 203 204 205 206 207 208
LIST(APPEND CGoGN_EXT_INCLUDES ${CGoGN_ROOT_DIR}/ThirdParty/OpenNL/src)
LIST(APPEND CGoGN_EXT_INCLUDES ${CGoGN_ROOT_DIR}/ThirdParty/tetgen)
LIST(APPEND CGoGN_EXT_INCLUDES ${CGoGN_ROOT_DIR}/ThirdParty/Zinri)
LIST(APPEND CGoGN_EXT_INCLUDES ${CGoGN_ROOT_DIR}/ThirdParty/Assimp/include/)
LIST(APPEND CGoGN_EXT_INCLUDES ${CGoGN_ROOT_DIR}/ThirdParty/TinyXml2)

IF (NOT WIN32)
	LIST(APPEND CGoGN_EXT_INCLUDES ${CGoGN_ROOT_DIR}/ThirdParty/libuuid)
ENDIF()

list(REMOVE_DUPLICATES CGoGN_EXT_INCLUDES)


Sylvain Thery's avatar
Sylvain Thery committed
209
# define libs for external libs
210
IF (CGoGN_WITH_ASSIMP)
211
	LIST(APPEND CGoGN_EXT_LIBS assimp)
212 213 214
	file(WRITE ${CGoGN_SRC_DIR}/include/cgogn_assimp.h "1" )
ELSE ()
	file(WRITE ${CGoGN_SRC_DIR}/include/cgogn_assimp.h "0" )
215
ENDIF ()
216

217
IF (CGoGN_WITH_ZINRI)
218
	LIST(APPEND CGoGN_EXT_LIBS Zinri)
219 220 221
	file(WRITE ${CGoGN_SRC_DIR}/include/cgogn_zinri.h "1" )
ELSE ()
	file(WRITE ${CGoGN_SRC_DIR}/include/cgogn_zinri.h "0" )
222
ENDIF ()
223 224 225 226

LIST(APPEND CGoGN_EXT_LIBS
    nl
    tinyxml2
Sylvain Thery's avatar
Sylvain Thery committed
227 228 229
	${OPENGL_LIBRARY}
	${GLEW_LIBRARIES}
	${ZLIB_LIBRARIES}
230
	${SUITESPARSE_LIBRARIES}
231
)
232

Sylvain Thery's avatar
Sylvain Thery committed
233 234 235
IF(NOT WIN32)
	LIST(APPEND CGoGN_EXT_LIBS pthread) #for c++11 thread
ENDIF()
236

237

238
include_directories( 
239
	${CGoGN_SRC_DIR}/include
240
	${CGoGN_EXT_INCLUDES} )
Sylvain Thery's avatar
Sylvain Thery committed
241

242 243 244 245 246 247 248 249 250 251 252 253 254 255 256
#
# save some infos for schnapps and apps
#
IF (CGoGN_ONELIB)
	file(WRITE ${CGoGN_SRC_DIR}/include/cgogn_onelib.h "1" )
ELSE ()
	file(WRITE ${CGoGN_SRC_DIR}/include/cgogn_onelib.h "0" )
ENDIF ()

IF (CGoGN_WITH_GLEWMX)
	file(WRITE ${CGoGN_SRC_DIR}/include/cgogn_gmx.h "1" )
ELSE ()
	file(WRITE ${CGoGN_SRC_DIR}/include/cgogn_gmx.h "0" )
ENDIF ()

Sylvain Thery's avatar
Sylvain Thery committed
257 258 259 260 261
IF (CGoGN_WITH_QT)
    file(WRITE ${CGoGN_ROOT_DIR}/CGoGN/include/cgogn_qt.h ${CGoGN_DESIRED_QT_VERSION})
ENDIF ()


262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277
file(WRITE ${CGoGN_SRC_DIR}/include/cgogn_ext_includes.h "" )
foreach(VAR_INC ${CGoGN_EXT_INCLUDES})
	file(APPEND ${CGoGN_SRC_DIR}/include/cgogn_ext_includes.h ${VAR_INC} \n )
endforeach()

file(WRITE ${CGoGN_SRC_DIR}/include/cgogn_ext_libs.h "" )
foreach(VAR_LIB ${CGoGN_EXT_LIBS})
	file(APPEND ${CGoGN_SRC_DIR}/include/cgogn_ext_libs.h ${VAR_LIB} \n )
endforeach()

file(WRITE ${CGoGN_SRC_DIR}/include/cgogn_defs.h "" )
foreach(VAR_DEF ${CGoGN_DEFS})
	file(APPEND ${CGoGN_SRC_DIR}/include/cgogn_defs.h ${VAR_DEF} \n )
endforeach()


278
add_subdirectory(${CGoGN_SRC_DIR} CGoGN)
Sylvain Thery's avatar
Sylvain Thery committed
279 280

add_subdirectory(${CGoGN_ROOT_DIR}/Apps Apps)
Sylvain Thery's avatar
Sylvain Thery committed
281 282 283 284 285


# 
# Add custom clean targets for cleaning without cleaning dependencies
#
Sylvain Thery's avatar
Sylvain Thery committed
286
if (NOT WIN32)
Sylvain Thery's avatar
Sylvain Thery committed
287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310
	add_custom_target(clean_cgogn 
			WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
	add_custom_command(TARGET clean_cgogn PRE_BUILD 
			COMMAND rm -rf CGoGN
			COMMAND cmake ..
			WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
			COMMENT "cleaning CGoGN libs")

	add_custom_target(clean_apps 
		WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
	add_custom_command(TARGET clean_apps PRE_BUILD 
			COMMAND rm -rf Apps
			COMMAND cmake ..
			WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
			COMMENT "cleaning Apps")

	add_custom_target(clean_cgogn_apps 
			WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
	add_custom_command(TARGET clean_cgogn_apps PRE_BUILD 
			COMMAND rm -rf CGoGN
			COMMAND rm -rf Apps
			COMMAND cmake ..
			WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
			COMMENT "cleaning Apps")
311
ENDIF()