Commit c0eed056 authored by Jan Möbius's avatar Jan Möbius

Dennis:

OpenMesh cmake support

git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@111 fdac6126-5c0c-442c-9429-916003d36597
parent a6af5944
cmake_minimum_required (VERSION 2.6)
project (OpenMesh)
# 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 ()
include (ACGOutput)
if (WIN32)
add_definitions(
-D_USE_MATH_DEFINES -DNOMINMAX
)
endif ()
add_subdirectory (src/OpenMesh/Core)
add_subdirectory (src/OpenMesh/Tools)
add_subdirectory (src/OpenMesh/Apps)
# display results
acg_print_configure_header ("OpenMesh")
2-0-RC2
$Name: $
VERSION=2.0-RC2
MAJOR=2
MINOR=0
PATCH=0
This diff is collapsed.
################################################################################
# Custom settings for compiler flags and similar
################################################################################
if (UNIX)
set (CMAKE_CFLAGS_RELEASE "-O3 -DINCLUDE_TEMPLATES -W -Wall -Wno-unused -DNDEBUG")
set (CMAKE_CXX_FLAGS_RELEASE "-O3 -DINCLUDE_TEMPLATES -ftemplate-depth-100 -W -Wall -Wno-unused -DNDEBUG")
set (CMAKE_C_FLAGS_DEBUG "-g -DINCLUDE_TEMPLATES -W -Wall -Wno-unused -DDEBUG")
set (CMAKE_CXX_FLAGS_DEBUG "-g -DINCLUDE_TEMPLATES -ftemplate-depth-100 -W -Wall -Wno-unused -DDEBUG")
if (APPLE)
add_definitions( -DARCH_DARWIN )
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wno-non-virtual-dtor")
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wno-non-virtual-dtor")
endif ()
endif ()
# fill string with spaces
macro (acg_format_string str length return)
string (LENGTH "${str}" _str_len)
math (EXPR _add_chr "${length} - ${_str_len}")
set (${return} "${str}")
while (_add_chr GREATER 0)
set (${return} "${${return}} ")
math (EXPR _add_chr "${_add_chr} - 1")
endwhile ()
endmacro ()
# print message with color escape sequences if CMAKE_COLOR_MAKEFILE is set
string (ASCII 27 _escape)
function (acg_color_message _str)
if (CMAKE_COLOR_MAKEFILE AND NOT WIN32)
message (${_str})
else ()
string (REGEX REPLACE "${_escape}.[0123456789;]*m" "" __str ${_str})
message (${__str})
endif ()
endfunction ()
# info header
function (acg_print_configure_header _name)
acg_format_string ("${_name}" 40 _project)
acg_format_string ("${VERSION}" 40 _version)
acg_color_message ("\n${_escape}[40;37m************************************************************${_escape}[0m")
acg_color_message ("${_escape}[40;37m* ${_escape}[1;31mACG ${_escape}[0;40;34mBuildsystem${_escape}[0m${_escape}[40;37m *${_escape}[0m")
acg_color_message ("${_escape}[40;37m* *${_escape}[0m")
acg_color_message ("${_escape}[40;37m* Package : ${_escape}[32m${_project} ${_escape}[37m *${_escape}[0m")
acg_color_message ("${_escape}[40;37m* Version : ${_escape}[32m${_version} ${_escape}[37m *${_escape}[0m")
acg_color_message ("${_escape}[40;37m************************************************************${_escape}[0m")
endfunction ()
# info line
function (acg_print_configure_footer)
acg_color_message ("${_escape}[40;37m************************************************************${_escape}[0m\n")
endfunction ()
# - Try to find GLEW
# Once done this will define
#
# GLEW_FOUND - system has GLEW
# GLEW_INCLUDE_DIR - the GLEW include directory
# GLEW_LIBRARY_DIR - where the libraries are
# GLEW_LIBRARY - Link these to use GLEW
#
IF (GLEW_INCLUDE_DIR)
# Already in cache, be silent
SET(GLEW_FIND_QUIETLY TRUE)
ENDIF (GLEW_INCLUDE_DIR)
if( WIN32 )
if( MSVC80 )
set( COMPILER_PATH "C:/Program\ Files/Microsoft\ Visual\ Studio\ 8/VC" )
endif( MSVC80 )
if( MSVC71 )
set( COMPILER_PATH "C:/Program\ Files/Microsoft\ Visual\ Studio\ .NET\ 2003/Vc7" )
endif( MSVC71 )
FIND_PATH( GLEW_INCLUDE_DIR gl/glew.h gl/wglew.h
PATHS c:/glew/include ${COMPILER_PATH}/PlatformSDK/Include )
SET( GLEW_NAMES glew32 )
FIND_LIBRARY( GLEW_LIBRARY
NAMES ${GLEW_NAMES}
PATHS c:/glew/lib ${COMPILER_PATH}/PlatformSDK/Lib )
else( WIN32 )
FIND_PATH( GLEW_INCLUDE_DIR glew.h wglew.h
PATHS /usr/local/include /usr/include
PATH_SUFFIXES gl/ GL/ )
SET( GLEW_NAMES glew GLEW )
FIND_LIBRARY( GLEW_LIBRARY
NAMES ${GLEW_NAMES}
PATHS /usr/lib /usr/local/lib )
endif( WIN32 )
GET_FILENAME_COMPONENT( GLEW_LIBRARY_DIR ${GLEW_LIBRARY} PATH )
IF (GLEW_INCLUDE_DIR AND GLEW_LIBRARY)
SET(GLEW_FOUND TRUE)
SET( GLEW_LIBRARY_DIR ${GLEW_LIBRARY} )
ELSE (GLEW_INCLUDE_DIR AND GLEW_LIBRARY)
SET( GLEW_FOUND FALSE )
SET( GLEW_LIBRARY_DIR )
ENDIF (GLEW_INCLUDE_DIR AND GLEW_LIBRARY)
# - Finds OpenMP support
# This module can be used to detect OpenMP support in a compiler.
# If the compiler supports OpenMP, the flags required to compile with
# openmp support are set.
#
# The following variables are set:
# OpenMP_C_FLAGS - flags to add to the C compiler for OpenMP support
# OpenMP_CXX_FLAGS - flags to add to the CXX compiler for OpenMP support
# OPENMP_FOUND - true if openmp is detected
#
# Supported compilers can be found at http://openmp.org/wp/openmp-compilers/
# Copyright 2008, 2009 <André Rigland Brodtkorb> Andre.Brodtkorb@ifi.uio.no
#
# Redistribution AND use is allowed according to the terms of the New
# BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
include(CheckCSourceCompiles)
include(CheckCXXSourceCompiles)
include(FindPackageHandleStandardArgs)
set(OpenMP_C_FLAG_CANDIDATES
#Gnu
"-fopenmp"
#Microsoft Visual Studio
"/openmp"
#Intel windows
"-Qopenmp"
#Intel
"-openmp"
#Empty, if compiler automatically accepts openmp
" "
#Sun
"-xopenmp"
#HP
"+Oopenmp"
#IBM XL C/c++
"-qsmp"
#Portland Group
"-mp"
)
set(OpenMP_CXX_FLAG_CANDIDATES ${OpenMP_C_FLAG_CANDIDATES})
# sample openmp source code to test
set(OpenMP_C_TEST_SOURCE
"
#include <omp.h>
int main() {
#ifdef _OPENMP
return 0;
#else
breaks_on_purpose
#endif
}
")
# use the same source for CXX as C for now
set(OpenMP_CXX_TEST_SOURCE ${OpenMP_C_TEST_SOURCE})
# if these are set then do not try to find them again,
# by avoiding any try_compiles for the flags
if(DEFINED OpenMP_C_FLAGS AND DEFINED OpenMP_CXX_FLAGS)
set(OpenMP_C_FLAG_CANDIDATES)
set(OpenMP_CXX_FLAG_CANDIDATES)
endif(DEFINED OpenMP_C_FLAGS AND DEFINED OpenMP_CXX_FLAGS)
# check c compiler
foreach(FLAG ${OpenMP_C_FLAG_CANDIDATES})
set(SAFE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
set(CMAKE_REQUIRED_FLAGS "${FLAG}")
set(OpenMP_C_FLAG_DETECTED)
message(STATUS "Try OpenMP C flag = [${FLAG}]")
check_c_source_compiles("${OpenMP_CXX_TEST_SOURCE}" OpenMP_C_FLAG_DETECTED)
set(CMAKE_REQUIRED_FLAGS "${SAFE_CMAKE_REQUIRED_FLAGS}")
if(OpenMP_C_FLAG_DETECTED)
set(OpenMP_C_FLAGS_INTERNAL "${FLAG}")
break()
endif(OpenMP_C_FLAG_DETECTED)
endforeach(FLAG ${OpenMP_C_FLAG_CANDIDATES})
# check cxx compiler
foreach(FLAG ${OpenMP_CXX_FLAG_CANDIDATES})
set(SAFE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
set(CMAKE_REQUIRED_FLAGS "${FLAG}")
set(OpenMP_CXX_FLAG_DETECTED)
message(STATUS "Try OpenMP CXX flag = [${FLAG}]")
check_cxx_source_compiles("${OpenMP_C_TEST_SOURCE}" OpenMP_CXX_FLAG_DETECTED)
set(CMAKE_REQUIRED_FLAGS "${SAFE_CMAKE_REQUIRED_FLAGS}")
if(OpenMP_CXX_FLAG_DETECTED)
set(OpenMP_CXX_FLAGS_INTERNAL "${FLAG}")
break()
endif(OpenMP_CXX_FLAG_DETECTED)
endforeach(FLAG ${OpenMP_CXX_FLAG_CANDIDATES})
set(OpenMP_C_FLAGS "${OpenMP_C_FLAGS_INTERNAL}"
CACHE STRING "C compiler flags for OpenMP parallization")
set(OpenMP_CXX_FLAGS "${OpenMP_CXX_FLAGS_INTERNAL}"
CACHE STRING "C++ compiler flags for OpenMP parallization")
# handle the standard arguments for find_package
find_package_handle_standard_args(OpenMP DEFAULT_MSG
OpenMP_C_FLAGS OpenMP_CXX_FLAGS )
mark_as_advanced(
OpenMP_C_FLAGS
OpenMP_CXX_FLAGS
)
include (ACGCommon)
# find needed packages
find_package (OpenGL)
find_package (GLUT)
find_package (GLEW)
acg_qt4 ()
add_subdirectory (Decimating/commandlineDecimater)
add_subdirectory (Smoothing)
add_subdirectory (Subdivider/commandlineSubdivider)
add_subdirectory (Subdivider/commandlineAdaptiveSubdivider)
add_subdirectory (mconvert)
# check for OpenGL, GLEW and GLUT as our required dependencies
if (QT4_FOUND AND OPENGL_FOUND AND GLEW_FOUND AND GLUT_FOUND)
add_subdirectory (Decimating/DecimaterGui)
add_subdirectory (QtViewer)
add_subdirectory (Subdivider/SubdividerGui)
else ()
if (NOT QT4_FOUND)
message ("QT 4 not found! Skipping some apps.")
endif ()
if (NOT OPENGL_FOUND)
message ("OpengGL not found! Skipping some apps.")
endif ()
if (NOT GLEW_FOUND)
message ("GLEW not found! Skipping some apps.")
endif ()
if (NOT GLUT_FOUND)
message ("GLUT not found! Skipping some apps.")
endif ()
endif ()
\ No newline at end of file
include (ACGCommon)
include_directories (
../../../..
${CMAKE_CURRENT_SOURCE_DIR}
)
set (targetName DecimaterGui)
# source code directories
set (directories
../../QtViewer
../
)
# collect all header and source files
acg_append_files (headers "*.hh" ${directories})
set (sources
../../QtViewer/QGLViewerWidget.cc
../../QtViewer/MeshViewerWidgetT.cc
../DecimaterViewerWidget.cc
../decimaterviewer.cc
)
# remove template cc files from source file list
acg_drop_templates (sources)
# genereate uic and moc targets
acg_qt4_automoc (moc_targets ${headers})
if (WIN32)
acg_add_executable (${targetName} WIN32 ${sources} ${headers} ${moc_targets})
# link to qtmain library to get WinMain function for a non terminal app
target_link_libraries (${targetName} ${QT_QTMAIN_LIBRARY})
else ()
acg_add_executable (${targetName} ${sources} ${headers} ${moc_targets})
endif ()
target_link_libraries (${targetName}
OpenMeshCore
OpenMeshTools
${QT_LIBRARIES}
${OPENGL_LIBRARIES}
${GLEW_LIBRARY}
${GLUT_LIBRARIES}
)
include (ACGCommon)
include_directories (
../../../..
${CMAKE_CURRENT_SOURCE_DIR}
)
set (targetName commandlineDecimater)
# collect all header and source files
set (sources
../decimater.cc
)
acg_add_executable (${targetName} ${sources})
target_link_libraries (${targetName}
OpenMeshCore
OpenMeshTools
)
include (ACGCommon)
include_directories (
../../..
${CMAKE_CURRENT_SOURCE_DIR}
)
set (targetName QtViewer)
# source code directories
set (directories
.
)
# collect all header and source files
acg_append_files (headers "*.hh" ${directories})
acg_append_files (sources "*.cc" ${directories})
acg_append_files (ui "*.ui" ${directories})
# remove template cc files from source file list
acg_drop_templates (sources)
# genereate uic and moc targets
acg_qt4_autouic (uic_targets ${ui})
acg_qt4_automoc (moc_targets ${headers})
if (WIN32)
acg_add_executable (${targetName} WIN32 ${uic_targets} ${sources} ${headers} ${moc_targets})
# link to qtmain library to get WinMain function for a non terminal app
target_link_libraries (${targetName} ${QT_QTMAIN_LIBRARY})
else ()
acg_add_executable (${targetName} ${uic_targets} ${sources} ${headers} ${moc_targets})
endif ()
target_link_libraries (${targetName}
OpenMeshCore
OpenMeshTools
${QT_LIBRARIES}
${OPENGL_LIBRARIES}
${GLEW_LIBRARY}
${GLUT_LIBRARIES}
)
include (ACGCommon)
include_directories (
../../..
${CMAKE_CURRENT_SOURCE_DIR}
)
set (targetName Smoothing)
# collect all header and source files
acg_append_files (headers "*.hh" .)
acg_append_files (sources "*.cc" .)
acg_add_executable (${targetName} ${headers} ${sources})
target_link_libraries (${targetName}
OpenMeshCore
OpenMeshTools
)
include (ACGCommon)
include_directories (
../../../..
${CMAKE_CURRENT_SOURCE_DIR}
)
set (targetName SubdividerGui)
# source code directories
set (directories
../../QtViewer
../
)
# collect all header and source files
acg_append_files (headers "*.hh" ${directories})
set (sources
../../QtViewer/QGLViewerWidget.cc
../../QtViewer/MeshViewerWidgetT.cc
../SubdivideWidget.cc
../qtsubdivider.cc
)
# remove template cc files from source file list
acg_drop_templates (sources)
# genereate uic and moc targets
acg_qt4_automoc (moc_targets ${headers})
if (WIN32)
acg_add_executable (${targetName} WIN32 ${sources} ${headers} ${moc_targets})
# link to qtmain library to get WinMain function for a non terminal app
target_link_libraries (${targetName} ${QT_QTMAIN_LIBRARY})
else ()
acg_add_executable (${targetName} ${sources} ${headers} ${moc_targets})
endif ()
target_link_libraries (${targetName}
OpenMeshCore
OpenMeshTools
${QT_LIBRARIES}
${OPENGL_LIBRARIES}
${GLEW_LIBRARY}
${GLUT_LIBRARIES}
)
include (ACGCommon)
include_directories (
../../../..
${CMAKE_CURRENT_SOURCE_DIR}
)
set (targetName commandlineAdaptiveSubdivider)
# collect all header and source files
set (sources
../adaptive_subdivider.cc
)
acg_add_executable (${targetName} ${sources})
target_link_libraries (${targetName}
OpenMeshCore
OpenMeshTools
)
include (ACGCommon)
include_directories (
../../../..
${CMAKE_CURRENT_SOURCE_DIR}
)
set (targetName commandlineSubdivider)
# collect all header and source files
set (sources
../subdivider.cc
)
acg_add_executable (${targetName} ${sources})
target_link_libraries (${targetName}
OpenMeshCore
OpenMeshTools
)
include (ACGCommon)
include_directories (
../../..
${CMAKE_CURRENT_SOURCE_DIR}
)
set (targetName mconvert)
# collect all header and source files
acg_append_files (headers "*.hh" .)
acg_append_files (sources "*.cc" .)
acg_add_executable (${targetName} ${headers} ${sources})
target_link_libraries (${targetName}
OpenMeshCore
OpenMeshTools
)
include (common)
include (ACGCommon)
include_directories (
../..
......@@ -21,20 +21,14 @@ set (directories
)
# collect all header and source files
append_files (headers "*.hh" ${directories})
append_files (sources "*.cc" ${directories})
acg_append_files (headers "*.hh" ${directories})
acg_append_files (sources "*.cc" ${directories})
if (WIN32)
# OpenMesh has no dll exports so we have to build a static library on windows
add_library (OpenMeshCore STATIC ${sources} ${headers})
acg_add_library (OpenMeshCore STATIC ${sources} ${headers})
else ()
add_library (OpenMeshCore SHARED ${sources} ${headers})
# no install on mac, because the whole bundle will be installed in the
# toplevel CMakeLists.txt
if (NOT APPLE)
install (TARGETS OpenMeshCore DESTINATION ${OPENFLIPPER_LIBDIR})
endif ()
acg_add_library (OpenMeshCore SHARED ${sources} ${headers})
endif ()
# set common target properties defined in common.cmake
set_target_props (OpenMeshCore)
include (common)
include (ACGCommon)
include_directories (
../..
......@@ -17,22 +17,15 @@ set (directories
)
# collect all header and source files
append_files (headers "*.hh" ${directories})
append_files (sources "*.cc" ${directories})
acg_append_files (headers "*.hh" ${directories})
acg_append_files (sources "*.cc" ${directories})
if (WIN32)
# OpenMesh has no dll exports so we have to build a static library on windows
add_library (OpenMeshTools STATIC ${sources} ${headers})
acg_add_library (OpenMeshTools STATIC ${sources} ${headers})
else ()
add_library (OpenMeshTools SHARED ${sources} ${headers})
# no install on mac, because the whole bundle will be installed in the
# toplevel CMakeLists.txt
if (NOT APPLE)
install (TARGETS OpenMeshTools DESTINATION ${OPENFLIPPER_LIBDIR})
endif ()
acg_add_library (OpenMeshTools SHARED ${sources} ${headers})
endif ()
target_link_libraries (OpenMeshTools OpenMeshCore)
# set common target properties defined in common.cmake
set_target_props (OpenMeshTools)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment