CMakeLists.txt 5.08 KB
Newer Older
Jan Möbius's avatar
   
Jan Möbius committed
1
include (ACGCommon)
Jan Möbius's avatar
Jan Möbius committed
2

Jan Möbius's avatar
Jan Möbius committed
3
4
acg_get_version ()

5
6
7
8
9
10
# Disable Library installation when not building ACG on its own but as part of another project!
if ( ${PROJECT_NAME} MATCHES "OpenFlipper")
  set(ACG_NO_LIBRARY_INSTALL true)
endif()


Matthias Möller's avatar
Matthias Möller committed
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27

if (NOT FORCE_QT4)
  # try to use QT5 if possible otherwise stick to QT4
  acg_qt5 ()  
else()
  set (QT_MAX_VERSION 4.9.9)
  set (QT5_FOUND false)
endif()


if (NOT QT5_FOUND)
  message(STATUS "Using QT4 for ACG")
  acg_qt4 (REQUIRED 4.5)
else ()
  message(STATUS "Using QT5 for ACG")
endif ()

Jan Möbius's avatar
   
Jan Möbius committed
28
29
acg_openmp ()

30
# check for OpenGL, GLEW and GLUT as our required dependencies
Jan Möbius's avatar
Jan Möbius committed
31
find_package (OpenGL)
Jan Möbius's avatar
   
Jan Möbius committed
32
33
34
35
if (NOT OPENGL_FOUND)
  message (FATAL_ERROR "OpengGL not found!")
endif ()

36
37
38
39
40
find_package (GLEW)
if (NOT GLEW_FOUND)
  message (FATAL_ERROR "GLEW not found!")
endif ()

Jan Möbius's avatar
   
Jan Möbius committed
41
42
43
44
find_package (GLUT)
if (NOT GLUT_FOUND)
  message (FATAL_ERROR "GLUT not found!")
endif ()
Jan Möbius's avatar
Jan Möbius committed
45

46
47
48
49
50
find_package (OpenMesh)
if (NOT OPENMESH_FOUND)
    message (FATAL_ERROR "OpenMesh not found!")
endif ()

51
set(INCLUDE_DIRS ${OPENMESH_INCLUDE_DIRS}
52
53
54
55
                 ${CMAKE_CURRENT_SOURCE_DIR}
                 ${CMAKE_CURRENT_SOURCE_DIR}/ShaderUtils
                 ${CMAKE_CURRENT_BINARY_DIR}
                 ${OPENGL_INCLUDE_DIR}
56
                 ${GLEW_INCLUDE_DIR}
57
58
                 ${GLUT_INCLUDE_DIR} )

Jan Möbius's avatar
Jan Möbius committed
59
set(ADDITIONAL_LINK_LIBRARIES "" )
60
set(ADDITIONAL_BUILD_DIRS "" )
61

62
63
64
65
66
67
find_package (QJson)
if (QJSON_FOUND)
    LIST(APPEND INCLUDE_DIRS ${QJSON_INCLUDE_DIR})
    LIST(APPEND ADDITIONAL_LINK_LIBRARIES ${QJSON_LIBRARY})
endif ()

68
69
70
71
72
73
74
# use Qwt6 for QT5
if (NOT FORCE_QT4 AND QT5_FOUND)
  find_package(Qwt6)

  if (QWT6_FOUND)
    set(INCLUDE_DIRS ${INCLUDE_DIRS} ${QWT6_INCLUDE_DIRS} )
    set(ADDITIONAL_LINK_LIBRARIES ${ADDITIONAL_LINK_LIBRARIES} ${QWT6_LIBRARIES})
75
    set(ADDITIONAL_BUILD_DIRS "QwtWidgets" )
76
77
78
  endif()
else()
  find_package(Qwt5)
79

80
81
82
  if(Qwt5_Qt4_FOUND)
    set(INCLUDE_DIRS ${INCLUDE_DIRS} ${Qwt5_INCLUDE_DIR} )
    set(ADDITIONAL_LINK_LIBRARIES ${ADDITIONAL_LINK_LIBRARIES} ${Qwt5_Qt4_LIBRARY})
83
    set(ADDITIONAL_BUILD_DIRS "QwtWidgets" )
84
  endif()
85
endif()
86

87
88
89
90
include_directories (
  ..
  ${INCLUDE_DIRS}
)
Jan Möbius's avatar
Jan Möbius committed
91
92

link_directories (
93
  ${GLEW_LIBRARY_DIR}
Jan Möbius's avatar
Jan Möbius committed
94
  ${GLUT_LIBRARY_DIR}
Jan Möbius's avatar
Jan Möbius committed
95
96
)

97
98
99
100
#===================================================================
# ACG Library setup
#===================================================================

Jan Möbius's avatar
Jan Möbius committed
101
# source code directories
Matthias Möller's avatar
Matthias Möller committed
102
set (directories
Jan Möbius's avatar
Jan Möbius committed
103
104
105
106
107
108
109
110
111
112
113
114
115
  .
  Geometry
  Config
  Geometry/Types
  GL
  Glut
  IO
  Math
  QtWidgets
  Scenegraph
  QtScenegraph
  ShaderUtils
  Utils
116
  ${ADDITIONAL_BUILD_DIRS}
Jan Möbius's avatar
Jan Möbius committed
117
118
)

Jan Möbius's avatar
Jan Möbius committed
119
# generate dllexport macros on windows
Jan Möbius's avatar
Jan Möbius committed
120
121
122
123
if (WIN32)
  add_definitions(-DACGDLL)
endif ()

Jan Möbius's avatar
Jan Möbius committed
124
# collect all header,source and ui files
Jan Möbius's avatar
   
Jan Möbius committed
125
126
127
acg_append_files (headers "*.hh" ${directories})
acg_append_files (sources "*.cc" ${directories})
acg_append_files (ui "*.ui" ${directories})
Jan Möbius's avatar
Jan Möbius committed
128

Jan Möbius's avatar
Jan Möbius committed
129
# remove template cc files from source file list
Jan Möbius's avatar
   
Jan Möbius committed
130
acg_drop_templates (sources)
Jan Möbius's avatar
Jan Möbius committed
131

Jan Möbius's avatar
Jan Möbius committed
132
# genereate uic and moc targets
Matthias Möller's avatar
Matthias Möller committed
133
134
135
136
137
138
139
140
if (QT5_FOUND)
  acg_qt5_autouic (uic_targets ${ui})
  acg_qt5_automoc (moc_targets ${headers})
elseif (QT4_FOUND)
  acg_qt4_autouic (uic_targets ${ui})
  acg_qt4_automoc (moc_targets ${headers})
endif()

Jan Möbius's avatar
Jan Möbius committed
141

Matthias Möller's avatar
Matthias Möller committed
142
143
144
145
146
if (QT5_FOUND)
  acg_add_library (ACG SHARED ${uic_targets} ${sources} ${headers} ${moc_targets})
elseif (QT4_FOUND)
  acg_add_library (ACG SHARED ${uic_targets} ${sources} ${headers} ${moc_targets})
endif()
Jan Möbius's avatar
Jan Möbius committed
147
if ( NOT WIN32 )
Jan Möbius's avatar
Jan Möbius committed
148
149
  set_target_properties (ACG PROPERTIES VERSION ${ACG_VERSION_MAJOR}.${ACG_VERSION_MINOR}
                                      SOVERSION ${ACG_VERSION_MAJOR}.${ACG_VERSION_MINOR})
Jan Möbius's avatar
Jan Möbius committed
150
endif()
Jan Möbius's avatar
Jan Möbius committed
151

152
153
154
155
if (NOT ACG_PROJECT_MACOS_BUNDLE OR NOT APPLE)
  install (TARGETS ACG DESTINATION ${ACG_PROJECT_LIBDIR})
endif ()

Jan Möbius's avatar
Jan Möbius committed
156
157
158
# display results
acg_print_configure_header (ACG "ACG")

159
target_link_libraries ( ACG  ${OPENMESH_LIBRARIES}
Jan Möbius's avatar
Jan Möbius committed
160
161
                             ${QT_LIBRARIES}
                             ${OPENGL_LIBRARIES}
162
                             ${GLEW_LIBRARY}
Jan Möbius's avatar
Jan Möbius committed
163
164
                             ${GLUT_LIBRARIES}
                             ${ADDITIONAL_LINK_LIBRARIES} )
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181

#===================================================================
# Setting up the unit tests
#===================================================================
find_package(GoogleTest)
if (GTEST_FOUND)
  enable_testing()
  file(GLOB_RECURSE TEST_SOURCES tests/*.cc)
  set(TESTED_SOURCES
        Algorithm/DBSCANT.cc
     )
  include_directories(${GTEST_INCLUDE_DIRS} ${OPENMESH_INCLUDE_DIR})
  link_directories ( ${GTEST_LIBRARY_DIR})

  if ( CMAKE_GENERATOR MATCHES "^Visual Studio 11.*" )
     add_definitions( /D _VARIADIC_MAX=10 )
  endif()
182
 
183
  add_executable (ACG_tests ${TEST_SOURCES})
184
185
186
187
188
189
190

  set(OUT_DIR ${CMAKE_CURRENT_BINARY_DIR})
  # run tests in build directory of OF
  if ( ${PROJECT_NAME} MATCHES "OpenFlipper" AND WIN32)
    set(OUT_DIR  ${CMAKE_BINARY_DIR}/Build)
  endif()

191
  set_target_properties(ACG_tests PROPERTIES
192
193
194
195
196
197
    COMPILE_FLAGS "-UNDEBUG"
    RUNTIME_OUTPUT_DIRECTORY ${OUT_DIR}
    RUNTIME_OUTPUT_DIRECTORY_RELEASE ${OUT_DIR}
    RUNTIME_OUTPUT_DIRECTORY_DEBUG ${OUT_DIR}
  )
  
198
199
200
  target_link_libraries(ACG_tests
        ${GTEST_LIBRARIES} ${OPENMESH_LIBRARIES} ACG
  )
201
202
  
  add_test(NAME AllTestsIn_ACG_tests COMMAND ${OUT_DIR}/ACG_tests)
203
endif(GTEST_FOUND)