CMakeLists.txt 4.65 KB
Newer Older
Jan Möbius's avatar
Revert  
Jan Möbius committed
1
cmake_minimum_required (VERSION 2.6)
2

3 4 5 6
# Only set project name if OpenMesh is built as stand-alone library
if("${PROJECT_NAME}" STREQUAL "")
    project (OpenMesh)
endif()
7 8

# add our macro directory to cmake search path
9
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
10
set (CMAKE_DEBUG_POSTFIX "d")
11 12 13 14 15 16

# include our cmake files
include (ACGCommon)

acg_get_version ()

17 18 19 20 21 22

# Disable package building when built as an external library
if(${PROJECT_NAME} MATCHES "OpenMesh")
    include(OpenMeshPackage)
endif()

23 24 25 26 27 28 29 30
include (ACGOutput)

if (WIN32)
  add_definitions(
      -D_USE_MATH_DEFINES -DNOMINMAX
  )
endif ()

31 32 33 34 35 36 37

# ========================================================================
# Windows build style control
# ========================================================================

if ( WIN32 )
  if ( NOT DEFINED OPENMESH_BUILD_SHARED )
38
    set( OPENMESH_BUILD_SHARED false CACHE BOOL "Build as shared library(DLL)?" )
39 40 41
  endif()
endif()

Jan Möbius's avatar
Jan Möbius committed
42 43 44
# ========================================================================
# Add bundle targets here
# ========================================================================
45 46 47 48
if ( NOT DEFINED BUILD_APPS )
  set( BUILD_APPS true CACHE BOOL "Enable or disable building of apps" )
endif()

49 50 51 52 53 54 55 56 57 58 59
# Only call fixbundle, when we are building OpenMesh standalone
if(${PROJECT_NAME} MATCHES "OpenMesh")

  if (WIN32)
    if ( NOT "${CMAKE_GENERATOR}" MATCHES "MinGW Makefiles" AND BUILD_APPS )
      add_custom_target (fixbundle ALL
        COMMAND ${CMAKE_COMMAND} -P "${CMAKE_BINARY_DIR}/fixbundle.win.cmake" )
    endif()
  endif()

  if (APPLE)
60
    add_custom_target (fixbundle ALL
61 62
      COMMAND ${CMAKE_COMMAND} -P "${CMAKE_BINARY_DIR}/fixbundle.cmake"
    )
63
  endif()
Jan Möbius's avatar
Jan Möbius committed
64

65
endif() # project OpenMesh
Jan Möbius's avatar
Jan Möbius committed
66 67 68 69 70

# ========================================================================
# Call the subdirectories with there projects
# ========================================================================

71 72 73
add_subdirectory (src/OpenMesh/Core)
add_subdirectory (src/OpenMesh/Tools)
add_subdirectory (src/OpenMesh/Apps)
74 75

# Do not build unit tests when build as external library
76
if(${PROJECT_NAME} MATCHES "OpenMesh")
77
    add_subdirectory (src/Unittests)
78 79 80 81 82 83 84 85 86 87 88 89 90 91
else()
	# If built as a dependent project simulate effects of
	# successful finder run:
	set (OPENMESH_FOUND true PARENT_SCOPE)
	set (OPENMESH_LIBRARIES OpenMeshCore OpenMeshTools PARENT_SCOPE)
	set (OPENMESH_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src" PARENT_SCOPE)

	# Also define variables provided by the old legacy finder.
	set (OPENMESH_CORE_LIBRARY OpenMeshCore PARENT_SCOPE)
	set (OPENMESH_TOOLS_LIBRARY OpenMeshTools PARENT_SCOPE)
	set (OPENMESH_TOOLS_LIBRARY OpenMeshTools PARENT_SCOPE)
	set (OPENMESH_LIBRARY OpenMeshCore OpenMeshTools PARENT_SCOPE)
	get_target_property(_OPENMESH_LIBRARY_DIR OpenMeshCore LIBRARY_OUTPUT_DIRECTORY)
	set (OPENMESH_LIBRARY_DIR "${_OPENMESH_LIBRARY_DIR}" CACHE PATH "The directory where the OpenMesh libraries can be found.")
92
endif()
93

94 95 96
add_subdirectory (Doc)

# ========================================================================
Jan Möbius's avatar
Jan Möbius committed
97
# Bundle generation (Targets exist, now configure them)
98 99
# ========================================================================

100 101
# Only call fixbundle, when we are building OpenMesh standalone
if(${PROJECT_NAME} MATCHES "OpenMesh")
102

103 104 105 106
  if (WIN32 AND  BUILD_APPS )
    # prepare bundle generation cmake file and add a build target for it
    configure_file ("${CMAKE_SOURCE_DIR}/cmake/fixbundle.cmake.win.in"
       "${CMAKE_BINARY_DIR}/fixbundle.win.cmake" @ONLY IMMEDIATE)
107

108 109 110 111 112 113
    if ( NOT "${CMAKE_GENERATOR}" MATCHES "MinGW Makefiles" )
      # let bundle generation depend on all targets
      add_dependencies (fixbundle QtViewer DecimaterGui)
    endif()
 
  endif()
Jan Möbius's avatar
Jan Möbius committed
114

115

116 117 118 119
  if (APPLE)
    # prepare bundle generation cmake file and add a build target for it
    configure_file ("${CMAKE_SOURCE_DIR}/cmake/fixbundle.cmake.in"
       "${CMAKE_BINARY_DIR}/fixbundle.cmake" @ONLY IMMEDIATE)
120

121 122 123 124 125 126 127 128 129
    # let bundle generation depend on all targets
    add_dependencies (fixbundle DecimaterGui ProgViewer QtViewer SubdividerGui) 

    # Required for Snow leopard, and the latest qt. Then the resources have to be copied
    if ( EXISTS "/opt/local/libexec/qt4-mac/lib/QtGui.framework/Versions/4/Resources/qt_menu.nib" )
        add_custom_command(TARGET OpenMesh POST_BUILD
           COMMAND ${CMAKE_COMMAND} -E copy_directory "/opt/local/libexec/qt4-mac/lib/QtGui.framework/Versions/4/Resources/qt_menu.nib" "${CMAKE_BINARY_DIR}/Build/Libraries/qt_menu.nib" 
          )
    endif ()
130
  
131 132 133
  endif ()

endif()
134 135 136 137 138 139

# ========================================================================


# display results
acg_print_configure_header (OPENMESH "OpenMesh")