2024-05-14 10:59:20 +02:00
|
|
|
cmake_minimum_required(VERSION 3.10.0 FATAL_ERROR)
|
2010-12-07 12:28:53 +00:00
|
|
|
|
2018-05-29 09:29:02 +02:00
|
|
|
|
|
|
|
|
# Set and enforce C++-11 flags
|
2023-06-26 16:26:19 +02:00
|
|
|
#set( CMAKE_CXX_STANDARD_REQUIRED TRUE )
|
|
|
|
|
#set( CMAKE_CXX_STANDARD 11 )
|
2018-05-29 09:29:02 +02:00
|
|
|
|
2014-09-16 11:15:29 +00:00
|
|
|
enable_testing()
|
|
|
|
|
|
2021-01-20 12:29:24 +01:00
|
|
|
|
2021-01-21 11:45:23 +01:00
|
|
|
project (OpenMesh
|
2023-11-17 10:13:23 +01:00
|
|
|
VERSION 11.0.0
|
2021-01-21 13:37:30 +01:00
|
|
|
LANGUAGES C CXX )
|
2010-12-07 12:28:53 +00:00
|
|
|
|
2020-04-30 09:13:30 +02:00
|
|
|
# Set AUTO UIC/MOC Policy to new for CMAKE 3.17 or higher
|
|
|
|
|
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.17")
|
|
|
|
|
cmake_policy(SET CMP0100 NEW)
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
|
2016-09-14 12:11:21 +02:00
|
|
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
|
|
|
|
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6.0" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "4.9" OR CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL "4.9")
|
|
|
|
|
message(WARNING "Your version of GCC contains an optimizer bug. Please verify that you do not use -O3!")
|
|
|
|
|
string(REPLACE "-O3" "-O2" CMAKE_CXX_FLAGS_RELEASE_NEW "${CMAKE_CXX_FLAGS_RELEASE}")
|
|
|
|
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE_NEW}" CACHE STRING "" FORCE)
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
|
2016-04-28 11:03:48 +02:00
|
|
|
if ( WIN32 )
|
|
|
|
|
# This is the base directory for windows library search used in the finders we ship.
|
|
|
|
|
set(CMAKE_WINDOWS_LIBS_DIR "c:/libs" CACHE STRING "Default Library search dir on windows." )
|
|
|
|
|
endif()
|
|
|
|
|
|
2015-03-11 11:30:14 +00:00
|
|
|
if (NOT WIN32 AND NOT CMAKE_BUILD_TYPE)
|
|
|
|
|
message(STATUS "No build type selected, default to Release")
|
|
|
|
|
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
|
|
|
|
|
endif()
|
|
|
|
|
|
2010-12-07 12:28:53 +00:00
|
|
|
# add our macro directory to cmake search path
|
2020-12-02 10:45:44 +01:00
|
|
|
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_CURRENT_SOURCE_DIR}/cmake-library/finders ${CMAKE_CURRENT_SOURCE_DIR}/cmake-library/VCI )
|
2011-08-31 09:21:17 +00:00
|
|
|
set (CMAKE_DEBUG_POSTFIX "d")
|
2010-12-07 12:28:53 +00:00
|
|
|
|
|
|
|
|
# include our cmake files
|
2020-12-07 13:18:53 +01:00
|
|
|
include (VCICommon)
|
2010-12-07 12:28:53 +00:00
|
|
|
|
2012-01-18 09:07:27 +00:00
|
|
|
# Disable package building when built as an external library
|
2021-01-20 12:39:17 +01:00
|
|
|
if(${CMAKE_PROJECT_NAME} MATCHES "OpenMesh")
|
2012-01-18 09:07:27 +00:00
|
|
|
include(OpenMeshPackage)
|
|
|
|
|
endif()
|
|
|
|
|
|
2020-12-07 13:18:53 +01:00
|
|
|
include (VCIOutput)
|
|
|
|
|
include(VCIQt)
|
2010-12-07 12:28:53 +00:00
|
|
|
|
2015-03-04 14:51:24 +00:00
|
|
|
# ========================================================================
|
|
|
|
|
# Definitions
|
|
|
|
|
# ========================================================================
|
|
|
|
|
|
2010-12-07 12:28:53 +00:00
|
|
|
if (WIN32)
|
|
|
|
|
add_definitions(
|
|
|
|
|
-D_USE_MATH_DEFINES -DNOMINMAX
|
2013-08-12 13:24:29 +00:00
|
|
|
-D_CRT_SECURE_NO_WARNINGS
|
2010-12-07 12:28:53 +00:00
|
|
|
)
|
|
|
|
|
endif ()
|
|
|
|
|
|
2015-03-04 14:51:24 +00:00
|
|
|
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()
|
2012-09-23 13:53:10 +00:00
|
|
|
|
|
|
|
|
# ========================================================================
|
|
|
|
|
# Windows build style control
|
|
|
|
|
# ========================================================================
|
|
|
|
|
|
|
|
|
|
if ( WIN32 )
|
|
|
|
|
if ( NOT DEFINED OPENMESH_BUILD_SHARED )
|
2012-09-24 14:12:15 +00:00
|
|
|
set( OPENMESH_BUILD_SHARED false CACHE BOOL "Build as shared library(DLL)?" )
|
2012-09-23 13:53:10 +00:00
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
|
2011-03-09 09:52:57 +00:00
|
|
|
# ========================================================================
|
|
|
|
|
# Add bundle targets here
|
|
|
|
|
# ========================================================================
|
2011-10-11 06:37:38 +00:00
|
|
|
if ( NOT DEFINED BUILD_APPS )
|
|
|
|
|
set( BUILD_APPS true CACHE BOOL "Enable or disable building of apps" )
|
|
|
|
|
endif()
|
|
|
|
|
|
2012-01-18 10:35:09 +00:00
|
|
|
# Only call fixbundle, when we are building OpenMesh standalone
|
2021-05-03 13:55:10 +02:00
|
|
|
if( (${CMAKE_PROJECT_NAME} MATCHES "OpenMesh") AND BUILD_APPS )
|
2012-01-18 10:35:09 +00:00
|
|
|
|
|
|
|
|
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)
|
2011-10-11 06:37:38 +00:00
|
|
|
add_custom_target (fixbundle ALL
|
2012-01-18 10:35:09 +00:00
|
|
|
COMMAND ${CMAKE_COMMAND} -P "${CMAKE_BINARY_DIR}/fixbundle.cmake"
|
|
|
|
|
)
|
2011-10-11 06:37:38 +00:00
|
|
|
endif()
|
2011-03-09 09:52:57 +00:00
|
|
|
|
2012-01-18 10:35:09 +00:00
|
|
|
endif() # project OpenMesh
|
2011-03-09 09:52:57 +00:00
|
|
|
|
|
|
|
|
# ========================================================================
|
|
|
|
|
# Call the subdirectories with there projects
|
|
|
|
|
# ========================================================================
|
|
|
|
|
|
2010-12-07 12:28:53 +00:00
|
|
|
add_subdirectory (src/OpenMesh/Core)
|
|
|
|
|
add_subdirectory (src/OpenMesh/Tools)
|
|
|
|
|
add_subdirectory (src/OpenMesh/Apps)
|
2012-01-18 09:48:05 +00:00
|
|
|
|
2015-11-19 19:53:36 +01:00
|
|
|
set(OPENMESH_BENCHMARK_DIR CACHE PATH "Source path of benchmark (https://github.com/google/benchmark).")
|
|
|
|
|
if (OPENMESH_BENCHMARK_DIR)
|
|
|
|
|
add_subdirectory(${OPENMESH_BENCHMARK_DIR} benchmark)
|
|
|
|
|
add_subdirectory(src/Benchmark)
|
|
|
|
|
endif()
|
|
|
|
|
|
2012-01-18 09:48:05 +00:00
|
|
|
# Do not build unit tests when build as external library
|
2021-01-20 12:39:17 +01:00
|
|
|
if(${CMAKE_PROJECT_NAME} MATCHES "OpenMesh")
|
2012-01-18 09:48:05 +00:00
|
|
|
add_subdirectory (src/Unittests)
|
2013-08-05 13:08:40 +00:00
|
|
|
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)
|
2017-03-15 15:38:50 +01:00
|
|
|
set (OPENMESH_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src" PARENT_SCOPE)
|
2013-08-05 13:08:40 +00:00
|
|
|
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.")
|
2013-02-20 12:25:03 +00:00
|
|
|
endif()
|
2012-01-18 09:48:05 +00:00
|
|
|
|
2019-04-09 07:45:54 +02:00
|
|
|
if ( NOT DEFINED OPENMESH_DOCS )
|
2019-04-09 08:09:22 +02:00
|
|
|
set( OPENMESH_DOCS true CACHE BOOL "Enable or disable building of documentation" )
|
2019-04-09 07:45:54 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
if (OPENMESH_DOCS)
|
|
|
|
|
add_subdirectory (Doc)
|
|
|
|
|
endif()
|
2010-12-07 12:28:53 +00:00
|
|
|
|
|
|
|
|
# ========================================================================
|
2011-03-09 09:52:57 +00:00
|
|
|
# Bundle generation (Targets exist, now configure them)
|
2010-12-07 12:28:53 +00:00
|
|
|
# ========================================================================
|
|
|
|
|
|
2012-01-18 10:35:09 +00:00
|
|
|
# Only call fixbundle, when we are building OpenMesh standalone
|
2021-01-20 12:39:17 +01:00
|
|
|
if(${CMAKE_PROJECT_NAME} MATCHES "OpenMesh")
|
2010-12-07 12:28:53 +00:00
|
|
|
|
2021-05-03 13:55:10 +02:00
|
|
|
if (WIN32 AND BUILD_APPS)
|
2012-01-18 10:35:09 +00:00
|
|
|
# prepare bundle generation cmake file and add a build target for it
|
2020-05-29 16:40:00 +02:00
|
|
|
configure_file ("${CMAKE_CURRENT_SOURCE_DIR}/cmake/fixbundle.cmake.win.in"
|
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/fixbundle.win.cmake" @ONLY IMMEDIATE)
|
2010-12-07 12:28:53 +00:00
|
|
|
|
2021-05-03 13:55:10 +02:00
|
|
|
if ( NOT "${CMAKE_GENERATOR}" MATCHES "MinGW Makefiles" )
|
2012-01-18 10:35:09 +00:00
|
|
|
# let bundle generation depend on all targets
|
|
|
|
|
add_dependencies (fixbundle QtViewer DecimaterGui)
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
endif()
|
2014-07-02 07:59:03 +00:00
|
|
|
|
|
|
|
|
# On apple we do a fixbundle, which is only necessary for the apps and not for the libs
|
2021-05-03 13:55:10 +02:00
|
|
|
if (APPLE AND BUILD_APPS)
|
2012-01-18 10:35:09 +00:00
|
|
|
# prepare bundle generation cmake file and add a build target for it
|
2020-05-29 16:42:54 +02:00
|
|
|
configure_file ("${CMAKE_SOURCE_DIR}/cmake/fixbundle.cmake.in"
|
|
|
|
|
"${CMAKE_BINARY_DIR}/fixbundle.cmake" @ONLY IMMEDIATE)
|
2010-12-07 14:00:28 +00:00
|
|
|
|
2012-01-18 10:35:09 +00:00
|
|
|
# let bundle generation depend on all targets
|
2021-05-03 14:03:27 +02:00
|
|
|
if (QT_FOUND)
|
|
|
|
|
add_dependencies (fixbundle DecimaterGui ProgViewer QtViewer SubdividerGui)
|
|
|
|
|
endif()
|
2012-01-18 10:35:09 +00:00
|
|
|
|
|
|
|
|
# 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
|
2014-07-02 07:59:03 +00:00
|
|
|
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" )
|
2012-01-18 10:35:09 +00:00
|
|
|
endif ()
|
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
|
|
endif()
|
2010-12-07 12:28:53 +00:00
|
|
|
|
|
|
|
|
# ========================================================================
|
|
|
|
|
|
2019-04-09 07:45:54 +02:00
|
|
|
# Generate openmesh.pc file
|
|
|
|
|
|
|
|
|
|
set(DEST_DIR "${CMAKE_INSTALL_PREFIX}")
|
|
|
|
|
set(PRIVATE_LIBS "-lOpenMeshCore -lOpenMeshTools")
|
|
|
|
|
|
|
|
|
|
configure_file("openmesh.pc.in" "${CMAKE_CURRENT_BINARY_DIR}/openmesh.pc" @ONLY)
|
|
|
|
|
|
2019-04-09 12:48:56 +02:00
|
|
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/openmesh.pc DESTINATION libdata/pkgconfig)
|
2019-04-09 07:45:54 +02:00
|
|
|
|
|
|
|
|
# generate target file
|
|
|
|
|
|
|
|
|
|
install(EXPORT OpenMeshConfig DESTINATION share/OpenMesh/cmake)
|
|
|
|
|
|
|
|
|
|
export(TARGETS OpenMeshCore OpenMeshTools FILE OpenMeshConfig.cmake)
|
2010-12-07 12:28:53 +00:00
|
|
|
|
|
|
|
|
# display results
|
2020-12-07 13:18:53 +01:00
|
|
|
vci_print_configure_header (OPENMESH "OpenMesh")
|