CMakeLists.txt 6.33 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)
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
#
# Available options
#
SET ( WITH_ASSIMP OFF CACHE BOOL "build CGoGN with Assimp" )
SET ( WITH_ZINRI OFF CACHE BOOL "build CGoGN with Zinri lib" )
SET ( WITH_QT ON CACHE BOOL "build CGoGN with Qt lib" )
SET ( DESIRED_QT_VERSION "4" CACHE STRING "4: QT4/ 5 not yet implemented" )
SET ( WITH_PYTHONQT ON CACHE BOOL "build PythonQt (for Schnapps)")
SET ( WITH_GLEWMX OFF CACHE BOOL "use multi-contex GLEW" )
SET ( USE_OGL_CORE_PROFILE OFF CACHE BOOL "use OpenGL 3.3 core profile (do not work on mac)" )

SET ( COMPILE_EXAMPLES OFF CACHE BOOL "compile examples" )
SET ( COMPILE_TUTOS OFF CACHE BOOL "compile tutorials" )
SET ( COMPILE_TESTS OFF CACHE BOOL "compile tests" )
SET ( COMPILE_BENCHES OFF CACHE BOOL "compile benches" )
SET ( COMPILE_SANDBOX OFF CACHE BOOL "compile all in sandbox" )
SET ( ASSERT_ACTIVED OFF CACHE BOOL "assertion activated")
SET ( ONELIB OFF CACHE BOOL "build CGoGN in one lib" )
IF (WIN32)
	SET ( BUILD_SHARED_LIBS OFF CACHE BOOL "if used all library are build as shared type (.so/.dylib/.dll)" )
	SET ( CMAKE_CONFIGURATION_TYPES Release Debug)
	SET ( CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING "Only Release or Debug" FORCE)
ELSE (WIN32)
	SET ( BUILD_SHARED_LIBS ON CACHE BOOL "if used all library are build as shared type (.so/.dylib/.dll)" )
ENDIF ()
40

41 42 43 44 45 46 47 48 49 50

checkCpp11Support()
setBuildType()


SET(EXECUTABLE_OUTPUT_PATH ${CGoGN_ROOT_DIR}/bin/)
IF(WIN32)
	SET(LIBRARY_OUTPUT_PATH ${CGoGN_ROOT_DIR}/lib)
ELSE()
	SET(LIBRARY_OUTPUT_PATH ${CGoGN_ROOT_DIR}/lib/${CMAKE_BUILD_TYPE})
51 52
ENDIF()

53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
#
# External Libraries (not included a third party libraries)
#
FIND_PACKAGE(OpenGL REQUIRED)
FIND_PACKAGE(ZLIB REQUIRED)
FIND_PACKAGE(GLEW REQUIRED)
IF (WITH_QT)
	SET(QT_USE_QTCORE TRUE)
	SET(QT_USE_QTOPENGL TRUE)
	SET(QT_USE_QTSVG TRUE)
	SET(QT_USE_QTXML TRUE )
	FIND_PACKAGE(Qt REQUIRED)
ELSE (WITH_QT)
	FIND_PACKAGE(DevIL REQUIRED)
ENDIF(WITH_QT)
IF (NOT WIN32)
	FIND_PACKAGE(SuiteSparse REQUIRED)
ENDIF()
Sylvain Thery's avatar
Sylvain Thery committed
71

72 73 74 75 76 77 78 79 80 81 82 83
#
# 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()
ENDIF()
84

85 86
if(APPLE)
	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated -Wno-overloaded-virtual")
87 88 89
endif()


90 91 92 93
#
# COMPILE DEFINITIONS
#
add_definitions("-DCGOGN_ASSERT_BOOL=${ASSERT_ACTIVED}")
94

95 96
IF(USE_OGL_CORE_PROFILE)
        add_definitions("-DUSE_OGL_CORE_PROFILE=1")
97 98
ENDIF()

99
add_definitions("-DGLM_FORCE_RADIANS")
100

101
add_definitions("-DSHADERPATH=\"${CGoGN_ROOT_DIR}/lib/Shaders/\"")
Sylvain Thery's avatar
Sylvain Thery committed
102

103 104 105
IF (WITH_ASSIMP)
	add_definitions(-DWITH_ASSIMP)	
ENDIF (WITH_ASSIMP)
106

107 108 109
IF (WITH_ZINRI)
	add_definitions(-DWITH_ZINRI)
ENDIF (WITH_ZINRI)
110

111 112 113
IF (WITH_GLEWMX)
	ADD_DEFINITIONS(-DGLEW_MX)
ENDIF (WITH_GLEWMX)
114

115

116 117 118 119
#
#	ThirdParty
#
#add_subdirectory(ThirdParty)
120

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

123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
ADD_SUBDIRECTORY(ThirdParty/Tools)

IF (WITH_PYTHONQT)
	ADD_SUBDIRECTORY(ThirdParty/PythonQt)
ENDIF (WITH_PYTHONQT)

ADD_SUBDIRECTORY(ThirdParty/OpenNL)
INCLUDE_DIRECTORIES(${CGoGN_ROOT_DIR}/ThirdParty/OpenNL/src)

ADD_SUBDIRECTORY(ThirdParty/tetgen)
INCLUDE_DIRECTORIES(${CGoGN_ROOT_DIR}/ThirdParty/tetgen)

IF (WITH_ZINRI)
	ADD_SUBDIRECTORY(ThirdParty/Zinri)
	INCLUDE_DIRECTORIES(${CGoGN_ROOT_DIR}/ThirdParty/Zinri)
ENDIF(WITH_ZINRI)

IF (WITH_ASSIMP)
	ADD_SUBDIRECTORY(ThirdParty/Assimp)
	INCLUDE_DIRECTORIES(${CGoGN_ROOT_DIR}/ThirdParty/Assimp/include/)
ENDIF (WITH_ASSIMP)
Sylvain Thery's avatar
Sylvain Thery committed
144

145 146 147 148 149 150 151
ADD_SUBDIRECTORY(ThirdParty/TinyXml2)
INCLUDE_DIRECTORIES(${CGoGN_ROOT_DIR}/ThirdParty/TinyXml2)

IF (WITH_QT)
	ADD_SUBDIRECTORY(ThirdParty/libQGLViewer/QGLViewer)
	INCLUDE_DIRECTORIES(${CGoGN_ROOT_DIR}/ThirdParty/libQGLViewer/)
ENDIF()
Sylvain Thery's avatar
Sylvain Thery committed
152

153 154 155 156
IF (NOT WIN32)
	ADD_SUBDIRECTORY(ThirdParty/libuuid)
	INCLUDE_DIRECTORIES(${CGoGN_ROOT_DIR}/ThirdParty/libuuid)
ENDIF()
157 158


159

160
IF (ONELIB)
161
	file(WRITE ${CGoGN_SRC_DIR}/include/cgogn_onelib.h "1" )
162
ELSE (ONELIB)
163
	file(WRITE ${CGoGN_SRC_DIR}/include/cgogn_onelib.h "0" )
164 165
ENDIF (ONELIB)

166
IF (WITH_GLEWMX)
167
	file(WRITE ${CGoGN_SRC_DIR}/include/cgogn_gmx.h "1" )
168
ELSE (WITH_GLEWMX)
169
	file(WRITE ${CGoGN_SRC_DIR}/include/cgogn_gmx.h "0" )
170 171 172
ENDIF (WITH_GLEWMX)


173 174 175 176 177 178 179 180 181 182 183 184 185 186 187
#
# INCLUDES AND LIBS
#
SET (CGoGN_EXT_INCLUDES)
SET (CGoGN_EXT_LIBS)
IF (WITH_QT)
		INCLUDE(${QT_USE_FILE})
        ADD_DEFINITIONS(-DWITH_QT)
        ADD_DEFINITIONS(${QT_DEFINITIONS})
        LIST(APPEND CGoGN_EXT_INCLUDES ${QT_INCLUDE_DIR})
        LIST(APPEND CGoGN_EXT_LIBS QGLViewer ${QT_LIBRARIES})
ELSE (WITH_QT)
	 LIST(APPEND CGoGN_EXT_INCLUDES ${IL_INCLUDE_DIR})
	 LIST(APPEND CGoGN_EXT_LIBS ${IL_LIBRARIES})
ENDIF (WITH_QT)
188

189
# define includes of external libs 
190 191
LIST(INSERT CGoGN_EXT_INCLUDES 0
    ${CGoGN_ROOT_DIR}/ThirdParty/include
192 193 194
	${OPENGL_INCLUDE_DIR}
	${GLEW_INCLUDE_DIRS}
	${ZLIB_INCLUDE_DIRS}
195
)
196 197

# define libs for external libs
198 199 200 201 202 203 204 205 206 207 208 209

IF (WITH_ASSIMP)
	LIST(APPEND CGoGN_EXT_LIBS assimp)
ENDIF (WITH_ASSIMP)

IF (WITH_ZINRI)
	LIST(APPEND CGoGN_EXT_LIBS Zinri)
ENDIF (WITH_ZINRI)

LIST(APPEND CGoGN_EXT_LIBS
    nl
    tinyxml2
210 211 212
	${OPENGL_LIBRARY}
	${GLEW_LIBRARIES}
	${ZLIB_LIBRARIES}
213
)
214

215
# W32 specific libraries and includes
216
IF(WIN32)
217 218 219 220
	INCLUDE_DIRECTORIES(${CGoGN_ROOT_DIR}/windows_dependencies/include/)
	INCLUDE_DIRECTORIES(${CGoGN_ROOT_DIR}/windows_dependencies/include/suitesparse)
	LIST(APPEND CGoGN_EXT_INCLUDES  ${CGoGN_ROOT_DIR}/windows_dependencies/include/suitesparse)
	LIST(APPEND CGoGN_EXT_LIBS 
221 222 223 224 225
		${CGoGN_ROOT_DIR}/windows_dependencies/lib/suitesparse.lib
		${CGoGN_ROOT_DIR}/windows_dependencies/lib/metis.lib
		${CGoGN_ROOT_DIR}/windows_dependencies/lib/liblapack.lib
		${CGoGN_ROOT_DIR}/windows_dependencies/lib/libblas.lib		)
ELSE(WIN32)
226 227
	LIST(APPEND CGoGN_EXT_INCLUDES  ${SUITESPARSE_INCLUDE_DIRS})
	LIST(APPEND CGoGN_EXT_LIBS ${SUITESPARSE_LIBRARIES} pthread)
228 229
ENDIF(WIN32)

unknown's avatar
unknown committed
230

231
#LIST(REMOVE_DUPLICATES CGoGN_EXT_INCLUDES)
232

233
include_directories( 
234
	${CGoGN_SRC_DIR}/include
235
	${CGoGN_EXT_INCLUDES} )
236 237


238
add_subdirectory(${CGoGN_SRC_DIR} CGoGN)
239 240

add_subdirectory(${CGoGN_ROOT_DIR}/Apps Apps)