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

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

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

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

# include our cmake files
include (ACGCommon)

acg_get_version ()

19
20
21
22
23
24

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

25
26
include (ACGOutput)

Matthias Möller's avatar
Matthias Möller committed
27
28
29
30
# ========================================================================
# Definitions
# ========================================================================

31
32
33
if (WIN32)
  add_definitions(
      -D_USE_MATH_DEFINES -DNOMINMAX
34
      -D_CRT_SECURE_NO_WARNINGS
35
36
37
  )
endif ()

Matthias Möller's avatar
Matthias Möller committed
38
39
40
41
set(NO_DECREMENT_DEPRECATED_WARNINGS OFF CACHE BOOL "Disables all deprecated warnings warning about decrement operations on normal circulators.")
if(NO_DECREMENT_DEPRECATED_WARNINGS)
  add_definitions( -DNO_DECREMENT_DEPRECATED_WARNINGS )
endif()
42
43
44
45
46
47
48

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

if ( WIN32 )
  if ( NOT DEFINED OPENMESH_BUILD_SHARED )
49
    set( OPENMESH_BUILD_SHARED false CACHE BOOL "Build as shared library(DLL)?" )
50
51
52
  endif()
endif()

Jan Möbius's avatar
Jan Möbius committed
53
54
55
# ========================================================================
# Add bundle targets here
# ========================================================================
56
57
58
59
if ( NOT DEFINED BUILD_APPS )
  set( BUILD_APPS true CACHE BOOL "Enable or disable building of apps" )
endif()

60
61
62
63
64
65
66
67
68
69
70
# 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)
71
    add_custom_target (fixbundle ALL
72
73
      COMMAND ${CMAKE_COMMAND} -P "${CMAKE_BINARY_DIR}/fixbundle.cmake"
    )
74
  endif()
Jan Möbius's avatar
Jan Möbius committed
75

76
endif() # project OpenMesh
Jan Möbius's avatar
Jan Möbius committed
77
78
79
80
81

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

82
83
84
add_subdirectory (src/OpenMesh/Core)
add_subdirectory (src/OpenMesh/Tools)
add_subdirectory (src/OpenMesh/Apps)
85
86

# Do not build unit tests when build as external library
87
if(${PROJECT_NAME} MATCHES "OpenMesh")
88
    add_subdirectory (src/Unittests)
89
90
91
92
93
94
95
96
97
98
99
100
101
102
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.")
103
endif()
104

105
106
add_subdirectory (Doc)

Jan Möbius's avatar
Jan Möbius committed
107
108
109
110
111
112
# ========================================================================
# Include Python interface
# ========================================================================

add_subdirectory (src/Python)

113
# ========================================================================
Jan Möbius's avatar
Jan Möbius committed
114
# Bundle generation (Targets exist, now configure them)
115
116
# ========================================================================

117
118
# Only call fixbundle, when we are building OpenMesh standalone
if(${PROJECT_NAME} MATCHES "OpenMesh")
119

120
121
122
123
  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)
124

125
126
127
128
129
130
    if ( NOT "${CMAKE_GENERATOR}" MATCHES "MinGW Makefiles" )
      # let bundle generation depend on all targets
      add_dependencies (fixbundle QtViewer DecimaterGui)
    endif()
 
  endif()
131
132
133
 
  # On apple we do a fixbundle, which is only necessary for the apps and not for the libs
  if (APPLE AND BUILD_APPS)
134
135
136
    # 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)
137

138
139
140
141
142
143
    # 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
144
145
           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" )
146
147
148
149
    endif ()
  endif ()

endif()
150
151
152
153
154
155

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


# display results
acg_print_configure_header (OPENMESH "OpenMesh")