apps_cmake.txt 4.55 KB
Newer Older
1
# A mettre juste apres la definition de CGoGN_ROOT_DIR a la racine du CGoGN_Apps
2
# include(${CGoGN_ROOT_DIR}/build/apps_cmake.txt)
3

Sylvain Thery's avatar
Sylvain Thery committed
4
SET(CMAKE_MODULE_PATH ${CGoGN_ROOT_DIR}/cmake_modules/)
5

Sylvain Thery's avatar
Sylvain Thery committed
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#SET ( WITH_ASSIMP ON CACHE BOOL "need Assimp")
#SET ( WITH_ZINRI ON CACHE BOOL "need Zinri lib")

IF(EXISTS "${CGoGN_ROOT_DIR}/ThirdParty/include/Assimp")
	SET ( WITH_ASSIMP ON CACHE BOOL "build CGoGN with Assimp" )
ELSE()
	SET ( WITH_ASSIMP OFF CACHE BOOL "build CGoGN with Assimp" )
ENDIF()

IF(EXISTS "${CGoGN_ROOT_DIR}/ThirdParty/include/Zinri")
	SET ( WITH_ZINRI ON CACHE BOOL "build CGoGN with Zinri lib" )
ELSE()
	SET ( WITH_ZINRI OFF CACHE BOOL "build CGoGN with Zinri lib" )
ENDIF()

21
SET ( WITH_QT ON CACHE BOOL "need Qt lib")
Sylvain Thery's avatar
Sylvain Thery committed
22

23

Pierre Kraemer's avatar
Pierre Kraemer committed
24
# for CGoGN in one lib or not
25
26
file(STRINGS ${CGoGN_ROOT_DIR}/include/cgogn_onelib.h ONELIB_STR)
IF (ONELIB_STR EQUAL 1)
Sylvain Thery's avatar
Sylvain Thery committed
27
28
29
30
	SET(CGoGN_LIBS cgogn)
ELSE()
	SET(CGoGN_LIBS topology algo container utils)
ENDIF()
31

Sylvain Thery's avatar
Sylvain Thery committed
32
33
34
35
36
IF(WIN32)
	set(CMAKE_PREFIX_PATH ${CGoGN_ROOT_DIR}/windows_dependencies CACHE STRING "path to dependencies")
ENDIF(WIN32)

find_package(OpenGL REQUIRED)
37
find_package(Boost COMPONENTS regex REQUIRED)
Sylvain Thery's avatar
Sylvain Thery committed
38
39
40
41
find_package(ZLIB REQUIRED)
find_package(LibXml2 REQUIRED)
find_package(GLEW REQUIRED)

42
43
44
45
46
47
IF (DEFINED ASSERTON)
	add_definitions(-DCGOGN_ASSERT_BOOL=${ASSERTON})
ELSE (DEFINED ASSERTON)
	add_definitions(-DCGOGN_ASSERT_BOOL=false)
ENDIF (DEFINED ASSERTON)

Sylvain Thery's avatar
Sylvain Thery committed
48
49
50
add_definitions(-DSHADERPATH="${CGoGN_ROOT_DIR}/lib/Shaders/")

# define includes of external libs 
Sylvain Thery's avatar
Sylvain Thery committed
51
SET(COMMON_INCLUDES 
52
	${CGoGN_ROOT_DIR}/ThirdParty/include
Sylvain Thery's avatar
Sylvain Thery committed
53
54
55
56
	${OPENGL_INCLUDE_DIR}
	${GLEW_INCLUDE_DIRS}
	${ZLIB_INCLUDE_DIRS}
	${LIBXML2_INCLUDE_DIR}
57
58
	${Boost_INCLUDE_DIRS}
)
Sylvain Thery's avatar
Sylvain Thery committed
59
60
61

# define libs for external libs
SET (COMMON_LIBS 
62
	nl
Sylvain Thery's avatar
Sylvain Thery committed
63
64
65
66
	${OPENGL_LIBRARY}
	${GLEW_LIBRARIES}
	${ZLIB_LIBRARIES}
	${LIBXML2_LIBRARIES}
67
	${Boost_SYSTEM_LIBRARY}
Sylvain Thery's avatar
Sylvain Thery committed
68
	${Boost_REGEX_LIBRARY}
69
)
Sylvain Thery's avatar
Sylvain Thery committed
70

71
72
73
74
75
76
77
78
79
80
81
IF(WIN32)
	SET (COMMON_INCLUDES ${COMMON_INCLUDES} ${CGoGN_ROOT_DIR}/windows_dependencies/include/suitesparse)
	SET (COMMON_LIBS ${COMMON_LIBS} 
		${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)
	find_package(SuiteSparse REQUIRED)
	SET (COMMON_INCLUDES ${COMMON_INCLUDES} ${SUITESPARSE_INCLUDE_DIRS})
	SET (COMMON_LIBS ${COMMON_LIBS} ${SUITESPARSE_LIBRARIES})
Thery Sylvain's avatar
Thery Sylvain committed
82

83
84
ENDIF(WIN32)

Sylvain Thery's avatar
Sylvain Thery committed
85
86
87
88
89
90
91
92
93
94
95
96
97
#optionnal libs
IF (WITH_ASSIMP)
	add_definitions(-DWITH_ASSIMP)	
	SET (COMMON_LIBS ${COMMON_LIBS} assimp)
ENDIF (WITH_ASSIMP)

IF (WITH_ZINRI)
	add_definitions(-DWITH_ZINRI)
	SET (COMMON_LIBS ${COMMON_LIBS} Zinri)
ENDIF (WITH_ZINRI)

IF (WITH_QT)
	add_definitions(-DWITH_QT)
Sylvain Thery's avatar
Sylvain Thery committed
98
99
	find_package(Qt4 REQUIRED)
	SET(QT_USE_QTCORE TRUE)
Sylvain Thery's avatar
Sylvain Thery committed
100
	SET(QT_USE_QTOPENGL TRUE)
Sylvain Thery's avatar
Sylvain Thery committed
101
102
	SET(QT_USE_QTSVG TRUE)
	SET(QT_USE_QTXML TRUE )
Sylvain Thery's avatar
Sylvain Thery committed
103
104
	INCLUDE(${QT_USE_FILE})
	ADD_DEFINITIONS(${QT_DEFINITIONS})
Sylvain Thery's avatar
Sylvain Thery committed
105
106
107
	find_package(QGLViewer REQUIRED)
	SET (COMMON_INCLUDES ${COMMON_INCLUDES} ${QT_INCLUDE_DIR} ${QGLVIEWER_INCLUDE_DIR})
	SET (COMMON_LIBS ${COMMON_LIBS} ${QT_LIBRARIES} ${QGLVIEWER_LIBRARIES})
Sylvain Thery's avatar
Sylvain Thery committed
108
109
ENDIF (WITH_QT)

110
IF(APPLE)
Thery Sylvain's avatar
Thery Sylvain committed
111
	SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -L/usr/local/lib")
112
113
ENDIF(APPLE)

Sylvain Thery's avatar
Sylvain Thery committed
114
# qq definition specifiques pour windows
115
IF(WIN32)
Sylvain Thery's avatar
Sylvain Thery committed
116
117
118
	set(CMAKE_PREFIX_PATH ${CGoGN_ROOT_DIR}/windows_dependencies CACHE STRING "path to dependencies")
	set(CMAKE_CONFIGURATION_TYPES Release Debug)
	set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING "Only Release or Debug" FORCE)
119
ELSE(WIN32)
Sylvain Thery's avatar
Sylvain Thery committed
120
	SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -fPIC -std=c++11")
Sylvain Thery's avatar
Sylvain Thery committed
121
122
	SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg")

Sylvain Thery's avatar
Sylvain Thery committed
123
124
125
126
127
128
129
	if(CMAKE_COMPILER_IS_GNUCXX)
		execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
		if (GCC_VERSION VERSION_GREATER 4.8 OR GCC_VERSION VERSION_EQUAL 4.8)
			SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-local-typedefs")
			SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-local-typedefs")
		endif(GCC_VERSION VERSION_GREATER 4.8 OR GCC_VERSION VERSION_EQUAL 4.8)
	endif(CMAKE_COMPILER_IS_GNUCXX)
130
131
ENDIF(WIN32)

Sylvain Thery's avatar
Sylvain Thery committed
132
SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin/${CMAKE_BUILD_TYPE})
Sylvain Thery's avatar
Sylvain Thery committed
133

134
135
136
IF(WIN32)
	link_directories( ${CGoGN_ROOT_DIR}/lib/ ${Boost_LIBRARY_DIRS} )
ELSE (WIN32)
Sylvain Thery's avatar
Sylvain Thery committed
137
	link_directories( ${CGoGN_ROOT_DIR}/lib/${CMAKE_BUILD_TYPE})
138
ENDIF (WIN32)
Sylvain Thery's avatar
Sylvain Thery committed
139
140
141
142
143
144
145
146

IF(NOT CMAKE_BUILD_TYPE)
	IF (${CMAKE_CURRENT_BINARY_DIR} MATCHES "(.*)Debug|(.*)debug")
		set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
	ELSE()
		set(CMAKE_BUILD_TYPE "Release" CACHE STRING "options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
	ENDIF()
ENDIF()