CMakeLists.txt 4.88 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 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
36
37
38
39
if (NOT OPENGL_FOUND)
  message (FATAL_ERROR "OpengGL not found!")
endif ()

find_package (GLUT)
if (NOT GLUT_FOUND)
  message (FATAL_ERROR "GLUT not found!")
endif ()
Jan Möbius's avatar
Jan Möbius committed
40

41
42
43
44
45
find_package (OpenMesh)
if (NOT OPENMESH_FOUND)
    message (FATAL_ERROR "OpenMesh not found!")
endif ()

46
set(INCLUDE_DIRS ${OPENMESH_INCLUDE_DIRS}
47
48
49
50
51
52
                 ${CMAKE_CURRENT_SOURCE_DIR}
                 ${CMAKE_CURRENT_SOURCE_DIR}/ShaderUtils
                 ${CMAKE_CURRENT_BINARY_DIR}
                 ${OPENGL_INCLUDE_DIR}
                 ${GLUT_INCLUDE_DIR} )

Jan Möbius's avatar
Jan Möbius committed
53
set(ADDITIONAL_LINK_LIBRARIES "" )
54
set(ADDITIONAL_BUILD_DIRS "" )
55

56
57
58
59
60
61
find_package (QJson)
if (QJSON_FOUND)
    LIST(APPEND INCLUDE_DIRS ${QJSON_INCLUDE_DIR})
    LIST(APPEND ADDITIONAL_LINK_LIBRARIES ${QJSON_LIBRARY})
endif ()

62
63
64
65
66
67
68
# 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})
69
    set(ADDITIONAL_BUILD_DIRS "QwtWidgets" )
70
71
72
  endif()
else()
  find_package(Qwt5)
73

74
75
76
  if(Qwt5_Qt4_FOUND)
    set(INCLUDE_DIRS ${INCLUDE_DIRS} ${Qwt5_INCLUDE_DIR} )
    set(ADDITIONAL_LINK_LIBRARIES ${ADDITIONAL_LINK_LIBRARIES} ${Qwt5_Qt4_LIBRARY})
77
    set(ADDITIONAL_BUILD_DIRS "QwtWidgets" )
78
  endif()
79
endif()
80

81
82
83
84
include_directories (
  ..
  ${INCLUDE_DIRS}
)
Jan Möbius's avatar
Jan Möbius committed
85
86

link_directories (
Jan Möbius's avatar
Jan Möbius committed
87
  ${GLUT_LIBRARY_DIR}
Jan Möbius's avatar
Jan Möbius committed
88
89
)

90
91
92
93
#===================================================================
# ACG Library setup
#===================================================================

Jan Möbius's avatar
Jan Möbius committed
94
# source code directories
Matthias Möller's avatar
Matthias Möller committed
95
set (directories
Jan Möbius's avatar
Jan Möbius committed
96
97
98
99
100
101
102
103
104
105
106
107
108
  .
  Geometry
  Config
  Geometry/Types
  GL
  Glut
  IO
  Math
  QtWidgets
  Scenegraph
  QtScenegraph
  ShaderUtils
  Utils
109
  ${ADDITIONAL_BUILD_DIRS}
Jan Möbius's avatar
Jan Möbius committed
110
111
)

Jan Möbius's avatar
Jan Möbius committed
112
# generate dllexport macros on windows
Jan Möbius's avatar
Jan Möbius committed
113
114
115
116
if (WIN32)
  add_definitions(-DACGDLL)
endif ()

Jan Möbius's avatar
Jan Möbius committed
117
# collect all header,source and ui files
Jan Möbius's avatar
   
Jan Möbius committed
118
119
120
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
121

Jan Möbius's avatar
Jan Möbius committed
122
# remove template cc files from source file list
Jan Möbius's avatar
   
Jan Möbius committed
123
acg_drop_templates (sources)
Jan Möbius's avatar
Jan Möbius committed
124

Jan Möbius's avatar
Jan Möbius committed
125
# genereate uic and moc targets
Matthias Möller's avatar
Matthias Möller committed
126
127
128
129
130
131
132
133
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
134

Matthias Möller's avatar
Matthias Möller committed
135
136
137
138
139
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
140
if ( NOT WIN32 )
Jan Möbius's avatar
Jan Möbius committed
141
142
  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
143
endif()
Jan Möbius's avatar
Jan Möbius committed
144

145
146
147
148
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
149
150
151
# display results
acg_print_configure_header (ACG "ACG")

152
target_link_libraries ( ACG  ${OPENMESH_LIBRARIES}
Jan Möbius's avatar
Jan Möbius committed
153
154
155
156
                             ${QT_LIBRARIES}
                             ${OPENGL_LIBRARIES}
                             ${GLUT_LIBRARIES}
                             ${ADDITIONAL_LINK_LIBRARIES} )
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173

#===================================================================
# 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()
174
 
175
  add_executable (ACG_tests ${TEST_SOURCES})
176
177
178
179
180
181
182

  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()

183
  set_target_properties(ACG_tests PROPERTIES
184
185
186
187
188
189
    COMPILE_FLAGS "-UNDEBUG"
    RUNTIME_OUTPUT_DIRECTORY ${OUT_DIR}
    RUNTIME_OUTPUT_DIRECTORY_RELEASE ${OUT_DIR}
    RUNTIME_OUTPUT_DIRECTORY_DEBUG ${OUT_DIR}
  )
  
190
191
192
  target_link_libraries(ACG_tests
        ${GTEST_LIBRARIES} ${OPENMESH_LIBRARIES} ACG
  )
193
194
  
  add_test(NAME AllTestsIn_ACG_tests COMMAND ${OUT_DIR}/ACG_tests)
195
endif(GTEST_FOUND)