Commit 9b790fd4 authored by Jan Möbius's avatar Jan Möbius

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@5917 383ad7c9-94d9-4d36-a494-682f7c89f535
parent c64bb48a
include (common)
# find needed packages
find_package (OpenGL)
find_package (GLUT)
find_package (GLEW)
ftgl ()
include (ACGCommon)
include_directories (
..
${CMAKE_SOURCE_DIR}/OpenMesh/src
${CMAKE_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
......@@ -41,32 +36,29 @@ set (directories
)
# collect all header,source and ui files
append_files (headers "*.hh" ${directories})
append_files (sources "*.cc" ${directories})
append_files (ui "*.ui" ${directories})
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
drop_templates (sources)
acg_drop_templates (sources)
# genereate uic and moc targets
qt4_autouic (uic_targets ${ui})
qt4_automoc (moc_targets ${headers})
acg_qt4_autouic (uic_targets ${ui})
acg_qt4_automoc (moc_targets ${headers})
if (WIN32)
# add app icon rc file to windows build
add_executable (OpenFlipper WIN32 ${CMAKE_CURRENT_SOURCE_DIR}/CoreApp.rc ${uic_targets} ${sources} ${headers} ${moc_targets})
acg_add_executable (OpenFlipper WIN32 ${CMAKE_CURRENT_SOURCE_DIR}/CoreApp.rc ${uic_targets} ${sources} ${headers} ${moc_targets})
# link to qtmain library to get WinMain function for a non terminal app
target_link_libraries (OpenFlipper ${QT_QTMAIN_LIBRARY})
elseif (APPLE)
# generate bundle on mac
add_executable (OpenFlipper MACOSX_BUNDLE ${uic_targets} ${sources} ${headers} ${moc_targets})
acg_add_executable (OpenFlipper MACOSX_BUNDLE ${uic_targets} ${sources} ${headers} ${moc_targets})
else ()
add_executable (OpenFlipper ${uic_targets} ${sources} ${headers} ${moc_targets})
acg_add_executable (OpenFlipper ${uic_targets} ${sources} ${headers} ${moc_targets})
endif ()
# set common target properties defined in common.cmake
set_target_props (OpenFlipper)
target_link_libraries (OpenFlipper
OpenMeshCore
OpenMeshTools
......@@ -89,29 +81,17 @@ if (APPLE)
MACOSX_BUNDLE_INFO_STRING "ACG OpenFlipper"
MACOSX_BUNDLE_ICON_FILE "Icons/OpenFlipper_Icon.icns"
)
else ()
install (TARGETS OpenFlipper DESTINATION ${OPENFLIPPER_BINDIR})
endif ()
if (WIN32)
# copy exe file to "Build" directory
# Visual studio will create this file in a subdirectory so we can't use
# RUNTIME_OUTPUT_DIRECTORY directly here
add_custom_command (TARGET OpenFlipper POST_BUILD
COMMAND ${CMAKE_COMMAND} -E
copy_if_different
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/OpenFlipper.exe
${CMAKE_BINARY_DIR}/Build/${OPENFLIPPER_BINDIR}/OpenFlipper.exe)
endif ()
# copy all needed files to "Build" directory to allow a direct execution from it
# the copy_after_build macro (common.cmake) copies the whole directory without svn files
copy_after_build (OpenFlipper "${CMAKE_CURRENT_SOURCE_DIR}/../Shaders" "${CMAKE_BINARY_DIR}/Build/${OPENFLIPPER_DATADIR}/Shaders")
copy_after_build (OpenFlipper "${CMAKE_CURRENT_SOURCE_DIR}/../Textures" "${CMAKE_BINARY_DIR}/Build/${OPENFLIPPER_DATADIR}/Textures")
copy_after_build (OpenFlipper "${CMAKE_CURRENT_SOURCE_DIR}/../Icons" "${CMAKE_BINARY_DIR}/Build/${OPENFLIPPER_DATADIR}/Icons")
copy_after_build (OpenFlipper "${CMAKE_CURRENT_SOURCE_DIR}/../Fonts" "${CMAKE_BINARY_DIR}/Build/${OPENFLIPPER_DATADIR}/Fonts")
copy_after_build (OpenFlipper "${CMAKE_CURRENT_SOURCE_DIR}/../Docs" "${CMAKE_BINARY_DIR}/Build/${OPENFLIPPER_DATADIR}/Docs")
copy_after_build (OpenFlipper "${CMAKE_CURRENT_SOURCE_DIR}/../Help" "${CMAKE_BINARY_DIR}/Build/${OPENFLIPPER_DATADIR}/Help")
acg_copy_after_build (OpenFlipper "${CMAKE_CURRENT_SOURCE_DIR}/../Shaders" "${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_DATADIR}/Shaders")
acg_copy_after_build (OpenFlipper "${CMAKE_CURRENT_SOURCE_DIR}/../Textures" "${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_DATADIR}/Textures")
acg_copy_after_build (OpenFlipper "${CMAKE_CURRENT_SOURCE_DIR}/../Icons" "${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_DATADIR}/Icons")
acg_copy_after_build (OpenFlipper "${CMAKE_CURRENT_SOURCE_DIR}/../Fonts" "${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_DATADIR}/Fonts")
acg_copy_after_build (OpenFlipper "${CMAKE_CURRENT_SOURCE_DIR}/../Docs" "${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_DATADIR}/Docs")
acg_copy_after_build (OpenFlipper "${CMAKE_CURRENT_SOURCE_DIR}/../Help" "${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_DATADIR}/Help")
if (NOT APPLE)
......@@ -119,10 +99,10 @@ if (NOT APPLE)
# the install_dir macro (common.cmake) installs the whole directory without svn files
# no install for mac needed here, because the whole bundle will be installed in the
# toplevel CMakeLists.txt
install_dir ("${CMAKE_CURRENT_SOURCE_DIR}/../Shaders" "${OPENFLIPPER_DATADIR}/Shaders")
install_dir ("${CMAKE_CURRENT_SOURCE_DIR}/../Textures" "${OPENFLIPPER_DATADIR}/Textures")
install_dir ("${CMAKE_CURRENT_SOURCE_DIR}/../Icons" "${OPENFLIPPER_DATADIR}/Icons")
install_dir ("${CMAKE_CURRENT_SOURCE_DIR}/../Fonts" "${OPENFLIPPER_DATADIR}/Fonts")
install_dir ("${CMAKE_CURRENT_SOURCE_DIR}/../Docs" "${OPENFLIPPER_DATADIR}/Docs")
install_dir ("${CMAKE_CURRENT_SOURCE_DIR}/../Help" "${OPENFLIPPER_DATADIR}/Help")
acg_install_dir ("${CMAKE_CURRENT_SOURCE_DIR}/../Shaders" "${ACG_PROJECT_DATADIR}/Shaders")
acg_install_dir ("${CMAKE_CURRENT_SOURCE_DIR}/../Textures" "${ACG_PROJECT_DATADIR}/Textures")
acg_install_dir ("${CMAKE_CURRENT_SOURCE_DIR}/../Icons" "${ACG_PROJECT_DATADIR}/Icons")
acg_install_dir ("${CMAKE_CURRENT_SOURCE_DIR}/../Fonts" "${ACG_PROJECT_DATADIR}/Fonts")
acg_install_dir ("${CMAKE_CURRENT_SOURCE_DIR}/../Docs" "${ACG_PROJECT_DATADIR}/Docs")
acg_install_dir ("${CMAKE_CURRENT_SOURCE_DIR}/../Help" "${ACG_PROJECT_DATADIR}/Help")
endif ()
\ No newline at end of file
include (common)
# find needed packages
find_package (OpenGL)
find_package (GLUT)
find_package (GLEW)
ftgl ()
include (ACGCommon)
include_directories (
..
${CMAKE_SOURCE_DIR}/OpenMesh/src
${CMAKE_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
......@@ -43,25 +38,22 @@ add_definitions (
)
# collect all header,source and ui files
append_files (headers "*.hh" ${directories})
append_files (sources "*.cc" ${directories})
append_files (ui "*.ui" ${directories})
acg_append_files (headers "*.hh" ${directories})
acg_append_files (sources "*.cc" ${directories})
acg_append_files (ui "*.ui" ${directories})
# add additional object type sources
append_files_recursive (headers "*.hh" ${CMAKE_SOURCE_DIR}/ObjectTypes)
append_files_recursive (sources "*.cc" ${CMAKE_SOURCE_DIR}/ObjectTypes)
acg_append_files_recursive (headers "*.hh" ${CMAKE_SOURCE_DIR}/ObjectTypes)
acg_append_files_recursive (sources "*.cc" ${CMAKE_SOURCE_DIR}/ObjectTypes)
# remove template cc files from source file list
drop_templates (sources)
acg_drop_templates (sources)
# genereate uic and moc targets
qt4_autouic (uic_targets ${ui})
qt4_automoc (moc_targets ${headers})
add_library (PluginLib SHARED ${uic_targets} ${sources} ${headers} ${moc_targets})
acg_qt4_autouic (uic_targets ${ui})
acg_qt4_automoc (moc_targets ${headers})
# set common target properties defined in common.cmake
set_target_props (PluginLib)
acg_add_library (PluginLib SHARED ${uic_targets} ${sources} ${headers} ${moc_targets})
target_link_libraries (PluginLib
OpenMeshCore
......@@ -73,20 +65,3 @@ target_link_libraries (PluginLib
${GLUT_LIBRARIES}
${FTGL_LIBS}
)
if (NOT APPLE)
# no install on mac, because the whole bundle will be installed in the
# toplevel CMakeLists.txt
install (TARGETS PluginLib DESTINATION ${OPENFLIPPER_LIBDIR})
endif ()
if (WIN32)
# copy dll file to "Build" directory
# Visual studio will create this file in a subdirectory so we can't use
# LIBRARY_OUTPUT_DIRECTORY directly here
add_custom_command (TARGET PluginLib POST_BUILD
COMMAND ${CMAKE_COMMAND} -E
copy_if_different
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/PluginLib.dll
${CMAKE_BINARY_DIR}/Build/${OPENFLIPPER_LIBDIR}/PluginLib.dll)
endif ()
\ No newline at end of file
set (ACG_PROJECT_MACOS_BUNDLE "1")
macro (acg_modify_project_dirs)
# set directory structures for the different platforms
if (WIN32)
add_definitions(
-D_USE_MATH_DEFINES -DNOMINMAX
-DOPENFLIPPER_APPDIR=".."
-DOPENFLIPPER_PLUGINDIR="${ACG_PROJECT_PLUGINDIR}"
-DOPENFLIPPER_DATADIR="${ACG_PROJECT_DATADIR}"
)
if (NOT EXISTS ${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_BINDIR})
file (MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_BINDIR})
endif ()
elseif (APPLE)
set (MAC_OPENFLIPPER_BASEDIR "OpenFlipper.app/Contents/Resources")
set (ACG_PROJECT_DATADIR "${MAC_ACG_PROJECT_BASEDIR}")
set (ACG_PROJECT_PLUGINDIR "${MAC_ACG_PROJECT_BASEDIR}/Plugins")
set (ACG_PROJECT_LIBDIR "${MAC_ACG_PROJECT_BASEDIR}/../MacOS")
set (ACG_PROJECT_BINDIR "${MAC_ACG_PROJECT_BASEDIR}/../MacOS")
add_definitions(
-DOPENFLIPPER_APPDIR="../Resources"
-DOPENFLIPPER_PLUGINDIR="Plugins"
-DOPENFLIPPER_DATADIR="."
)
else ()
add_definitions(
-DOPENFLIPPER_APPDIR=".."
-DOPENFLIPPER_PLUGINDIR="${ACG_PROJECT_PLUGINDIR}"
-DOPENFLIPPER_DATADIR="${ACG_PROJECT_DATADIR}"
)
endif ()
endmacro ()
# search all plugins and add them to build
function (of_add_plugins)
file (
GLOB _plugins_in
RELATIVE "${CMAKE_SOURCE_DIR}"
"${CMAKE_SOURCE_DIR}/Plugin-*/CMakeLists.txt"
)
foreach (_plugin ${_plugins_in})
get_filename_component (_plugin_dir ${_plugin} PATH)
add_subdirectory (${CMAKE_SOURCE_DIR}/${_plugin_dir})
endforeach ()
endfunction ()
# print plugin statistics
function (of_print_plugin_stats)
acg_color_message ("\n${_escape}[4mPlugin configure check results:${_escape}[0m\n")
file (
GLOB _plugins_in
RELATIVE "${CMAKE_SOURCE_DIR}"
"${CMAKE_SOURCE_DIR}/Plugin-*"
)
foreach (_plugin ${_plugins_in})
string (REPLACE "Plugin-" "" _plugin_name ${_plugin})
string (TOUPPER ${_plugin_name} _PLUGIN)
if (NOT EXISTS ${CMAKE_SOURCE_DIR}/${_plugin}/CMakeLists.txt AND DISABLE_QMAKE_BUILD)
list (APPEND CPACK_SOURCE_IGNORE_FILES "${CMAKE_SOURCE_DIR}/${_plugin}")
elseif (DISABLE_PLUGIN_${_PLUGIN})
list (APPEND CPACK_SOURCE_IGNORE_FILES "${CMAKE_SOURCE_DIR}/${_plugin}")
endif ()
endforeach ()
foreach (_plugin ${_plugins_in})
string (REPLACE "Plugin-" "" _plugin_name ${_plugin})
string (TOUPPER ${_plugin_name} _PLUGIN)
acg_format_string (${_plugin_name} 20 _plugin_name)
if (DISABLE_PLUGIN_${_PLUGIN})
acg_color_message (" ${_plugin_name}: ${_escape}[1;34mDisabled${_escape}[0m")
elseif (NOT EXISTS ${CMAKE_SOURCE_DIR}/${_plugin}/CMakeLists.txt)
acg_color_message (" ${_plugin_name}: ${_escape}[1;34mNo CMake build system${_escape}[0m")
else ()
if (OPENFLIPPER_${_PLUGIN}_BUILD)
acg_color_message (" ${_plugin_name}: ${_escape}[1;32mYes${_escape}[0m")
else ()
acg_color_message (" ${_plugin_name}: ${_escape}[1;31mNo${_escape}[0m (Missing dependencies :${_${_PLUGIN}_MISSING_DEPS})")
endif ()
endif ()
endforeach ()
message ("")
endfunction ()
# gp_item_default_embedded_path_override item default_embedded_path_var
#
# Return the path that others should refer to the item by when the item
# is embedded inside a bundle.
#
# This is a project-specific override of BundleUtilities.cmake's
# gp_item_default_embedded_path
#
function(gp_item_default_embedded_path_override item default_embedded_path_var)
# By default, embed items as set by gp_item_default_embedded_path:
#
set(path "${${default_embedded_path_var}}")
# But for OpenFlipper...
#
# ...embed *.dylib in the Libraries folder:
#
if(item MATCHES "\\.dylib$")
set(path "@executable_path/../Libraries")
endif()
# ...embed qt plugins in the Libraries folder:
#
if(item MATCHES "@QT_PLUGINS_DIR@/.*\\.dylib$")
file (RELATIVE_PATH _plugin "@QT_PLUGINS_DIR@" "${item}")
get_filename_component(_dir "${_plugin}" PATH)
set(path "@executable_path/../Resources/QtPlugins/${_dir}")
endif()
# ...embed *.so in the Plugins folder:
#
if(item MATCHES "\\.so$")
set(path "@executable_path/../Resources/Plugins")
endif()
set(${default_embedded_path_var} "${path}" PARENT_SCOPE)
endfunction(gp_item_default_embedded_path_override)
include (BundleUtilities)
# copy qt plugins to bundle
file (GLOB _plugins "@CMAKE_BINARY_DIR@/Build/OpenFlipper.app/Contents/Resources/Plugins/*.so")
file (GLOB_RECURSE _qtplugins "@QT_PLUGINS_DIR@/*.dylib")
foreach (_qtp ${_qtplugins})
get_filename_component(_dir "${_qtp}" PATH)
list(APPEND _qtdirs "${_dir}")
endforeach ()
# fix all dependencies
fixup_bundle (@CMAKE_BINARY_DIR@/Build/OpenFlipper.app "${_plugins};${_qtplugins}" "/usr/lib;${_qtdirs}")
# create qt plugin configuration file
file(WRITE "@CMAKE_BINARY_DIR@/Build/OpenFlipper.app/Contents/Resources/qt.conf" "[Paths]\nPlugins = Resources/QtPlugins")
# option to disable inclusion of qmake build system into source package
option (
DISABLE_QMAKE_BUILD
"Disable inclusion of qmake build system into source package"
OFF
)
# set name
set (CPACK_PACKAGE_NAME "OpenFlipper")
set (CPACK_PACKAGE_VENDOR "ACG")
# set version
set (CPACK_PACKAGE_VERSION_MAJOR "${VERSION_MAJOR}")
set (CPACK_PACKAGE_VERSION_MINOR "${VERSION_MINOR}")
set (CPACK_PACKAGE_VERSION_PATCH "${VERSION_PATCH}")
set (CPACK_PACKAGE_VERSION "${VERSION}")
# addition package info
set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "OpenFlipper Mesh manipulation too")
set (CPACK_PACKAGE_EXECUTABLES "OpenFlipper;OpenFlipper")
set (CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
set (CPACK_PACKAGE_INSTALL_REGISTRY_KEY "${CPACK_PACKAGE_NAME}")
set (CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
set (CPACK_SOURCE_STRIP_FILES "")
# set (CPACK_PACKAGE_DESCRIPTION_FILE "/home/andy/vtk/CMake/Copyright.txt")
# set (CPACK_RESOURCE_FILE_LICENSE "/home/andy/vtk/CMake/Copyright.txt")
# set (CPACK_RESOURCE_FILE_README "/home/andy/vtk/CMake/Templates/CPack.GenericDescription.txt")
# set (CPACK_RESOURCE_FILE_WELCOME "/home/andy/vtk/CMake/Templates/CPack.GenericWelcome.txt")
set (CPACK_STRIP_FILES "bin/OpenFlipper")
# source package generation
set (CPACK_SOURCE_GENERATOR "TGZ;TBZ2;ZIP")
# ignored files in source package
set (CPACK_SOURCE_IGNORE_FILES "\\\\.#;/#;.*~")
list (APPEND CPACK_SOURCE_IGNORE_FILES "/\\\\.git")
list (APPEND CPACK_SOURCE_IGNORE_FILES "/\\\\.svn")
list (APPEND CPACK_SOURCE_IGNORE_FILES "${CMAKE_CURRENT_BINARY_DIR}")
list (APPEND CPACK_SOURCE_IGNORE_FILES "Makefile")
list (APPEND CPACK_SOURCE_IGNORE_FILES "Makefile\\\\..*")
list (APPEND CPACK_SOURCE_IGNORE_FILES "\\\\.moc\\\\.cpp$")
list (APPEND CPACK_SOURCE_IGNORE_FILES "CMakeCache.txt")
list (APPEND CPACK_SOURCE_IGNORE_FILES "CMakeFiles")
list (APPEND CPACK_SOURCE_IGNORE_FILES "/.*_(32|64)_Debug/")
list (APPEND CPACK_SOURCE_IGNORE_FILES "/.*_(32|64)_Release/")
list (APPEND CPACK_SOURCE_IGNORE_FILES "/MacOS")
list (APPEND CPACK_SOURCE_IGNORE_FILES "/WIN")
list (APPEND CPACK_SOURCE_IGNORE_FILES "/tmp/")
list (APPEND CPACK_SOURCE_IGNORE_FILES "/.*\\\\.kdevelop")
list (APPEND CPACK_SOURCE_IGNORE_FILES "/.*\\\\.kdevses")
list (APPEND CPACK_SOURCE_IGNORE_FILES "/ACG/lib/")
list (APPEND CPACK_SOURCE_IGNORE_FILES "/ACG/include/")
if (DISABLE_QMAKE_BUILD)
list (APPEND CPACK_SOURCE_IGNORE_FILES "/.*\\\\.pro")
list (APPEND CPACK_SOURCE_IGNORE_FILES "/qmake/")
list (APPEND CPACK_SOURCE_IGNORE_FILES "\\\\.qmake\\\\.cache")
endif ()
# filter out all disabled plugins
file (
GLOB _plugins_in
RELATIVE "${CMAKE_SOURCE_DIR}"
"${CMAKE_SOURCE_DIR}/Plugin-*"
)
foreach (_plugin ${_plugins_in})
string (REPLACE "Plugin-" "" _plugin_name ${_plugin})
string (TOUPPER ${_plugin_name} _PLUGIN)
if (NOT EXISTS ${CMAKE_SOURCE_DIR}/${_plugin}/CMakeLists.txt AND DISABLE_QMAKE_BUILD)
list (APPEND CPACK_SOURCE_IGNORE_FILES "${CMAKE_SOURCE_DIR}/${_plugin}")
elseif (DISABLE_PLUGIN_${_PLUGIN})
list (APPEND CPACK_SOURCE_IGNORE_FILES "${CMAKE_SOURCE_DIR}/${_plugin}")
endif ()
endforeach ()
if (WIN32)
# window NSIS installer
set (CPACK_GENERATOR "NSIS")
set (CPACK_PACKAGE_INSTALL_DIRECTORY "${CPACK_PACKAGE_NAME} ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}")
set (CPACK_NSIS_DISPLAY_NAME "OpenFlipper v${CPACK_PACKAGE_VERSION}")
set (CPACK_NSIS_MUI_ICON "${CMAKE_SOURCE_DIR}\\\\OpenFlipper\\\\Icons\\\\OpenFlipper_Icon_128x128x32.ico")
# we need a real uninstaller icon here and we have to define both to make the installer icon work
set (CPACK_NSIS_MUI_UNIICON "${CMAKE_SOURCE_DIR}\\\\OpenFlipper\\\\Icons\\\\OpenFlipper_Icon_128x128x32.ico")
set (CPACK_PACKAGE_ICON "${CMAKE_SOURCE_DIR}\\\\OpenFlipper\\\\Icons\\\\installer.bmp")
set (CPACK_NSIS_HELP_LINK "http:\\\\www.openflipper.org")
set (CPACK_NSIS_URL_INFO_ABOUT "http:\\\\www.openflipper.org")
# TODO: fillme
# set (CPACK_NSIS_CONTACT "")
# append dll's to installed package
if (EXISTS ${CMAKE_SOURCE_DIR}/WIN)
file (GLOB _files "${CMAKE_SOURCE_DIR}/WIN/DLLs/DLLs 32 debug/*.dll")
install(FILES ${_files}
DESTINATION ${ACG_PROJECT_LIBDIR}
CONFIGURATIONS Debug
)
file (GLOB _files "${CMAKE_SOURCE_DIR}/WIN/DLLs/DLLs 32 release/*.dll")
install (FILES ${_files}
DESTINATION ${ACG_PROJECT_LIBDIR}
CONFIGURATIONS Release
)
endif ()
elseif (APPLE)
# apple Drag'n'Drop installer package
set (CPACK_GENERATOR "DragNDrop;TGZ")
set (CPACK_PACKAGE_ICON "${CMAKE_SOURCE_DIR}/OpenFlipper/Icons/OpenFlipper_Icon.icns")
endif ()
# has to be last
include (InstallRequiredSystemLibraries)
include (CPack)
if (NOT WIN32 AND NOT APPLE)
# no binary target for linux
file (REMOVE "${CMAKE_BINARY_DIR}/CPackConfig.cmake")
endif ()
# cmake doesn't create a source package target, so we have to add our own
if (EXISTS "${CMAKE_BINARY_DIR}/CPackSourceConfig.cmake")
add_custom_target (PACKAGE_SOURCE
${CMAKE_CPACK_COMMAND} --config "${CMAKE_BINARY_DIR}/CPackSourceConfig.cmake"
)
endif ()
# This module provides the following macro:
#
# openflipper_plugin ( [DIRS dir1 dir2 ...]
# [DEPS dep1 dep2 ...]
# [OPTDEPS dep1 dep2 ...]
# [LDFLAGSADD flag1 flag2 ...]
# [CFLAGSADD flag1 flag2 ...]
# [LIBRARIES lib1 lib2 ...]
# [LIBDIRS dir1 dir2 ...]
# [INCDIRS dir1 dir2 ...]
# [ADDSRC file1 file2 ...])
#
# DIRS = additional directories with source files
# DEPS = required dependencies for find_package macro
# OPTDEPS = optional dependencies for find_package macro
# LDFLAGSADD = flags added to the link command
# CFLAGSADD = flags added to the compile command
# LIBRARIES = libraries added to link command
# LIBDIRS = additional link directories
# INCDIRS = additional include directories
# ADDSRC = additional source files
#
# Plugins can implement a acg_list_filter ("listname") macro to filter out
# unneeded headers, sources and ui files from the autogenerated
# build sources lists (see common.cmake drop_templates macro)
#
include (ACGCommon)
# get plugin name from directory name
macro (_get_plugin_name var)
string (REGEX MATCH "Plugin-.+[/\\]?$" _dir ${CMAKE_CURRENT_SOURCE_DIR})
string (REPLACE "Plugin-" "" ${var} ${_dir})
endmacro ()
# parse plugin macro parameter
macro (_get_plugin_parameters _prefix)
set (_current_var _foo)
set (_supported_var DIRS DEPS OPTDEPS LDFLAGSADD CFLAGSADD LIBRARIES LIBDIRS INCDIRS ADDSRC)
foreach (_val ${_supported_var})
set (${_prefix}_${_val})
endforeach ()
foreach (_val ${ARGN})
set (_found FALSE)
foreach (_find ${_supported_var})
if ("${_find}" STREQUAL "${_val}")
set (_found TRUE)
endif ()
endforeach ()
if (_found)
set (_current_var ${_prefix}_${_val})
else ()
list (APPEND ${_current_var} ${_val})
endif ()
endforeach ()
endmacro ()
# check dependencies
macro (_check_plugin_deps _prefix)
set (${_prefix}_HAS_DEPS TRUE)
foreach (_val ${ARGN})
string (TOUPPER ${_val} _VAL)
find_package(${_val})
if (${_val}_FOUND OR ${_VAL}_FOUND)
foreach (_name ${_val} ${_VAL})
if (DEFINED ${_name}_INCLUDE_DIRS)
list (APPEND ${_prefix}_DEPS_INCDIRS "${${_name}_INCLUDE_DIRS}")
endif ()
if (DEFINED ${_name}_LIBRARY_DIRS)
list (APPEND ${_prefix}_DEPS_LIBDIRS "${${_name}_LIBRARY_DIRS}")
endif ()
if (DEFINED ${_name}_LIBRARIES)
list (APPEND ${_prefix}_DEPS_LIBRARIES "${${_name}_LIBRARIES}")
endif ()
if (DEFINED ${_name}_LINKER_FLAGS)
list (APPEND ${_prefix}_DEPS_LINKER_FLAGS "${${_name}_LINKER_FLAGS}")
endif ()
endforeach ()
else ()
set (${_prefix}_HAS_DEPS FALSE)
acg_set (_${_prefix}_MISSING_DEPS "${_${_prefix}_MISSING_DEPS} ${_val}")
endif ()
endforeach ()
endmacro ()
# main function
function (_build_openflipper_plugin plugin)
acg_set (OPENFLIPPER_${_PLUGIN}_BUILD "0")
# get upper plugin name
string (TOUPPER ${plugin} _PLUGIN)
# parse parameters
_get_plugin_parameters (${_PLUGIN} ${ARGN})
# check dependencies
acg_unset (_${_PLUGIN}_MISSING_DEPS)
set (${_PLUGIN}_HAS_DEPS)
_check_plugin_deps (${_PLUGIN} ${${_PLUGIN}_OPTDEPS})
acg_unset (_${_PLUGIN}_MISSING_DEPS)
set (${_PLUGIN}_HAS_DEPS)
_check_plugin_deps (${_PLUGIN} ${${_PLUGIN}_DEPS})
if (${_PLUGIN}_HAS_DEPS)
include_directories (
.
${CMAKE_SOURCE_DIR}
${CMAKE_SOURCE_DIR}/OpenMesh/src
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${${_PLUGIN}_DEPS_INCDIRS}
${${_PLUGIN}_INCDIRS}
${OPENGL_INCLUDE_DIR}
${GLEW_INCLUDE_DIR}
${GLUT_INCLUDE_DIR}
)
link_directories (
${${_PLUGIN}_DEPS_LIBDIRS}
${${_PLUGIN}_LIBDIRS}
)
set (directories
.
${${_PLUGIN}_DIRS}
)
# collect all header,source and ui files
acg_append_files (headers "*.hh" ${directories})
acg_append_files (sources "*.cc" ${directories})
acg_append_files (sources "*.c" ${directories})
acg_append_files (ui "*.ui" ${directories})
# remove template cc files from source file list
acg_drop_templates (sources)
# filter header,source and ui files lists if acg_list_filter macro has been defined
if (COMMAND acg_list_filter)
acg_list_filter (headers)
acg_list_filter (sources)
acg_list_filter (ui)
endif ()
# genereate uic and moc targets
acg_qt4_autouic (uic_targets ${ui})
acg_qt4_automoc (moc_targets ${headers})
add_library (Plugin-${plugin} MODULE ${uic_targets} ${sources} ${headers} ${moc_targets} ${${_PLUGIN}_ADDSRC})
# add this plugin to build plugin list for dependency tracking
acg_set (OPENFLIPPER_PLUGINS "${OPENFLIPPER_PLUGINS};Plugin-${plugin}")
acg_set (OPENFLIPPER_${_PLUGIN}_BUILD "1")
# append compiler and linker flags from plugin dependencies
set_target_properties (
Plugin-${plugin} PROPERTIES
COMPILE_FLAGS "${${_PLUGIN}_CFLAGSADD}"
LINK_FLAGS "${${_PLUGIN}_LDFLAGSADD} ${${_PLUGIN}_DEPS_LINKER_FLAGS}"
)
if (WIN32)