CMakeLists.txt 8.44 KB
Newer Older
Jan Möbius's avatar
Jan Möbius committed
1
cmake_minimum_required (VERSION 2.8.4)
2 3 4 5 6 7 8 9 10 11 12 13 14 15

project (OpenFlipper)

# add our macro directory to cmake search path
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake)

# include our cmake files
include (ACGCommon)

acg_get_version (OpenFlipper)

include (package)
include (ACGOutput)

Jan Möbius's avatar
Jan Möbius committed
16 17

acg_qt4 (4.7.0)
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
acg_openmp ()
acg_ftgl ()

# check for OpenGL, GLEW and GLUT as our required dependencies
find_package (OpenGL)
if (NOT OPENGL_FOUND)
  message (FATAL_ERROR "OpengGL not found!")
endif ()

find_package (GLEW)
if (NOT GLEW_FOUND)
  message (FATAL_ERROR "GLEW not found!")
endif ()

find_package (GLUT)
if (NOT GLUT_FOUND)
  message (FATAL_ERROR "GLUT not found!")
endif ()
36 37 38 39
find_package (OpenMesh)
if (NOT OPENMESH_FOUND)
    message (FATAL_ERROR "OpenMesh not found!")
endif ()
40 41 42 43
find_package (OpenVolumeMesh)
if (NOT OPENVOLUMEMESH_FOUND)
    message (FATAL_ERROR "OpenVolumeMesh not found!")
endif ()
44

45

46 47 48 49 50 51 52 53 54 55
# ========================================================================
# Configure the executables path for tests
# ========================================================================
if (APPLE)
  SET( OPENFLIPPER_EXECUTABLE "${CMAKE_BINARY_DIR}/Build/OpenFlipper.app/Contents/MacOS/OpenFlipper" )
elseif( WIN32 )
  SET( OPENFLIPPER_EXECUTABLE "${CMAKE_BINARY_DIR}/Build/OpenFlipper.exe" )
else()
  SET( OPENFLIPPER_EXECUTABLE "${CMAKE_BINARY_DIR}/Build/bin/OpenFlipper" )
endif()
56 57 58
SET(OPENFLIPPER_TEST_FILES    ${CMAKE_BINARY_DIR}/tests/globalTestFiles )
SET(OPENFLIPPER_TEST_RESULTS  ${CMAKE_BINARY_DIR}/tests/testResults )
SET(OPENFLIPPER_TEST_BINARIES ${CMAKE_BINARY_DIR}/tests/testBinaries )
59

60 61
enable_testing()

62
# ========================================================================
Jan Möbius's avatar
Jan Möbius committed
63
# Core Library Components (Except the Core application)
64 65 66 67
# ========================================================================
add_subdirectory (ACG)
add_subdirectory (OpenFlipper/PluginLib)

68 69 70
# ========================================================================
# Tests
# ========================================================================
Jan Möbius's avatar
Jan Möbius committed
71
add_subdirectory (tests)
72

73 74 75 76 77 78 79 80 81 82
# ========================================================================
# Documentation generators  
# ========================================================================

# Create dirs to make doxygen happy
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_DATADIR}/Doc ) 
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_DATADIR}/Help ) 

# Add the deocumentation targets
add_subdirectory (OpenFlipper/Documentation/DeveloperTarget)
Jan Möbius's avatar
Jan Möbius committed
83
add_subdirectory (OpenFlipper/Documentation/DeveloperQtHelpTarget)
84
add_subdirectory (OpenFlipper/Documentation/UserTarget)
Jan Möbius's avatar
Jan Möbius committed
85
add_subdirectory (OpenFlipper/Documentation/UserQtHelpTarget)
86 87 88 89 90 91 92


# ========================================================================
# Build all additional libraries  
# ========================================================================

# search all libs in the libs directory 
93
# (required and optional libraries
94 95 96
file (
  GLOB _local_libs_in
  RELATIVE "${CMAKE_SOURCE_DIR}"
97 98
           "${CMAKE_SOURCE_DIR}/libs/*/CMakeLists.txt"
           "${CMAKE_SOURCE_DIR}/libs_required/*/CMakeLists.txt"
99 100
)

Jan Möbius's avatar
Jan Möbius committed
101 102 103 104 105

set( REMAINING_LOCAL_LIBS "" )

# Special Comiso case:
# The library has to be configured first
106
foreach (_localLib ${_local_libs_in})
Jan Möbius's avatar
Jan Möbius committed
107 108
  if ( "${_localLib}" MATCHES .*CoMISo.* )
    get_filename_component (_local_lib_dir ${_localLib} PATH)
109 110 111 112 113 114 115
    if ( NOT DEFINED LIB_COMISO_BUILD )
      set( LIB_COMISO_BUILD true CACHE BOOL "Enable or disable build of COMISO Library" )
    endif()

    if ( LIB_COMISO_BUILD )
      add_subdirectory (${CMAKE_SOURCE_DIR}/${_local_lib_dir})
    endif()
Jan Möbius's avatar
Jan Möbius committed
116 117 118 119 120 121 122 123
  else()
    LIST(APPEND REMAINING_LOCAL_LIBS ${_localLib})
  endif()
endforeach ()


# add all found libs to the build
foreach (_localLib ${REMAINING_LOCAL_LIBS})
124

125
  get_filename_component (_local_lib_dir ${_localLib} PATH)
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143

  # If the library is in the required folder, we have to build it anyway, so
  # detect it here
  SET(REQUIRED FALSE) 
  if ( _localLib MATCHES ".*libs_required.*" )
    SET(REQUIRED TRUE )
  endif()

  # Extract upper case library dir name for the human readable entries in the cmake config
  string(TOUPPER ${_local_lib_dir} _local_lib_dir_upper)
  string(REGEX REPLACE "LIBS[/\\]" "" _local_lib_dir_upper ${_local_lib_dir_upper} )
 
  # Only generate setting if the lib is not required (otherwise, we will always build it)
  if ( NOT DEFINED LIB_${_local_lib_dir_upper}_BUILD AND NOT REQUIRED)
      set( LIB_${_local_lib_dir_upper}_BUILD true CACHE BOOL "Enable or disable build of ${_local_lib_dir_upper} Library" )
  endif()

  # Build if this library is required or if it is enabled
Jan Möbius's avatar
Jan Möbius committed
144
  if ( LIB_${_local_lib_dir_upper}_BUILD OR REQUIRED)
145 146
    add_subdirectory (${CMAKE_SOURCE_DIR}/${_local_lib_dir})
  endif()
147 148
endforeach ()

149 150 151 152 153 154 155 156
# ========================================================================
# PolyLine extension special case
# ========================================================================

if ( EXISTS ${CMAKE_SOURCE_DIR}/libs/MeshIntegration ) 
  add_definitions( -DEXTENDED_POLY_LINE )
endif()

157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181
# ========================================================================
# License Manager
# ========================================================================
if ( NOT DEFINED OPENFLIPPER_ENABLE_LICENSE_MANAGER )
  set( OPENFLIPPER_ENABLE_LICENSE_MANAGER true CACHE BOOL "Enable or disable license management in all plugins" )
endif()

# ========================================================================
# Apple Mac Store Flags
# ========================================================================
if ( APPLE AND NOT DEFINED OPENFLIPPER_BUILD_APP_STORE_COMPLIANT )
  set( OPENFLIPPER_BUILD_APP_STORE_COMPLIANT true CACHE BOOL "Enable app store compliant build (No internal update, different paths,...)" )
endif()


# ========================================================================
# Plugins
# ========================================================================

# start with an empty plugin list
acg_set (OPENFLIPPER_PLUGINS "")

# add plugins
of_add_plugins ()

Jan Möbius's avatar
Jan Möbius committed
182 183 184
# ========================================================================
# Build core as we now know all dependencies
# ========================================================================
185

Jan Möbius's avatar
Jan Möbius committed
186
add_subdirectory (OpenFlipper/CoreApp)
187

188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214

# ========================================================================
# Bundle generation
# ========================================================================

if (WIN32 )

  # Plugins collected a list of required libdirs for getting 
  # their DLLS on windows:
  get_property( WINDOWS_COPY_LIBDIRS GLOBAL PROPERTY WINDOWS_LIBRARY_DIR_LIST )
  
  if ( WINDOWS_COPY_LIBDIRS )
    list(REMOVE_DUPLICATES WINDOWS_COPY_LIBDIRS)
  endif()

  # prepare bundle generation cmake file and add a build target for it
  configure_file ("${CMAKE_SOURCE_DIR}/OpenFlipper/cmake/fixbundle.cmake.win.in"
     "${CMAKE_BINARY_DIR}/fixbundle.win.cmake" @ONLY IMMEDIATE)

  add_custom_target (fixbundle ALL
    COMMAND ${CMAKE_COMMAND} -P "${CMAKE_BINARY_DIR}/fixbundle.win.cmake" )

  # let bundle generation depend on all targets
  add_dependencies (fixbundle OpenFlipper PluginLib ${OPENFLIPPER_PLUGINS})
 
endif(WIN32)

215 216 217 218 219 220
# ========================================================================
# Apple Mac Store Flags
# ========================================================================
if ( APPLE AND NOT DEFINED OPENFLIPPER_CALL_FIX_BUNDLE )
  set( OPENFLIPPER_CALL_FIX_BUNDLE true CACHE BOOL "After building OpenFlipper, a bundle creation step is executed (which copies all dependencies into the bundle) to create a valid MacOs Bundle." )
endif()
221

222
if (APPLE AND OPENFLIPPER_CALL_FIX_BUNDLE)
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244
  # prepare bundle generation cmake file and add a build target for it
  configure_file ("${CMAKE_SOURCE_DIR}/OpenFlipper/cmake/fixbundle.cmake.in"
     "${CMAKE_BINARY_DIR}/fixbundle.cmake" @ONLY IMMEDIATE)
  add_custom_target (fixbundle ALL
    COMMAND ${CMAKE_COMMAND} -P "${CMAKE_BINARY_DIR}/fixbundle.cmake"
  )
  # let bundle generation depend on all targets
  add_dependencies (fixbundle OpenFlipper PluginLib ${OPENFLIPPER_PLUGINS})

  # install bundle
  install (DIRECTORY ${CMAKE_BINARY_DIR}/Build/OpenFlipper.app DESTINATION .
           USE_SOURCE_PERMISSIONS)
endif ()

# ========================================================================
# Output log information
# ========================================================================

# display results
acg_print_configure_header (OPENFLIPPER "OpenFlipper")
of_print_plugin_stats ()
acg_print_configure_footer ()