Commit 4d7f7208 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[ADD] - modules compile. Only two modules have their own CmakeLists...

[ADD] - modules compile. Only two modules have their own CmakeLists (Template-Module: for documentation/example and DetTractClustering: cuda stuff). The others are handled automatically.
parent c26257d8
......@@ -345,6 +345,7 @@ ADD_CUSTOM_TARGET( many
# This script contains all the needed tools to setup the build
INCLUDE( ${PROJECT_SOURCE_DIR}/../tools/CMakeModules/BuildUtils.cmake )
INCLUDE( ${PROJECT_SOURCE_DIR}/../tools/CMakeModules/BuildModuleUtils.cmake )
# libcnt needs absolute inclusion somewhere
INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/ext/libeep )
......@@ -380,3 +381,12 @@ SET( OWBinaryName "walnut" )
# build core
ADD_SUBDIRECTORY( qt4gui )
# -----------------------------------------------------------------------------------------------------------------------------------------------
# Modules
# where to put the modules by default?
SET( OWModuleTargetDir ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/OpenWalnut )
# build modules
ADD_SUBDIRECTORY( modules )
......@@ -61,7 +61,7 @@ void WPathHelper::setAppPath( boost::filesystem::path appPath )
m_sharePath = m_appPath / "../share/OpenWalnut";
m_configPath = m_appPath / "../etc/OpenWalnut";
m_libPath = m_appPath / "../lib";
m_modulePath = m_libPath / "modules";
m_modulePath = m_libPath / "OpenWalnut";
}
boost::filesystem::path WPathHelper::getAppPath()
......
......@@ -153,6 +153,6 @@ void WModuleLoader::load( WSharedAssociativeContainer< std::set< boost::shared_p
std::string WModuleLoader::getModulePrefix()
{
// all module file names need to have this prefix:
return WSharedLib::getSystemPrefix() + "OWmodule";
return WSharedLib::getSystemPrefix();
}
# ---------------------------------------------------------------------------------------------------------------------------------------------------
#
# Some modules need third party libraries. We provide them if they are available
#
# ---------------------------------------------------------------------------------------------------------------------------------------------------
# -----------------------------------------------------------------------------------------------------------------------------------------------
# Teem: http://teem.sourceforge.org
# - NOTE: you need the SVN version
FIND_PACKAGE( Teem PATHS /usr/local/lib /opt/teem/lib QUIET )
IF( Teem_FOUND ) # we need to add the include path and lib path to allow the compiler and linker to find teem even if it was not installed to
# /usr/local
INCLUDE_DIRECTORIES( ${Teem_INCLUDE_DIRS} )
LINK_DIRECTORIES( ${LINK_DIRECTORIES} ${Teem_LIBRARY_DIRS} )
ENDIF()
# -----------------------------------------------------------------------------------------------------------------------------------------------
# Cuda: http://www.nvidia.com
# - NOTE: you need the SVN version
OPTION( OW_USE_CUDA "Enable CUDA if available. Minimum version required is 2.3" )
IF( OW_USE_CUDA )
FIND_PACKAGE( CUDA QUIET )
IF( CUDA_FOUND )
# BugFix: Subsequent calls don't set CUDA_VERSION_MAJOR or .._MINOR variables, so we have to extract them from CUDA_VERSION variable
STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+).*" "\\1" CUDA_VERSION_MAJOR ${CUDA_VERSION})
STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+).*" "\\2" CUDA_VERSION_MINOR ${CUDA_VERSION})
# Enforce at least CUDA version 2.3, since the detTractClustering is know to require this at least
SET( OW_MIN_CUDA_MAJOR_VERSION 2 )
SET( OW_MIN_CUDA_MINOR_VERSION 3 )
IF( CUDA_VERSION_MAJOR LESS OW_MIN_CUDA_MAJOR_VERSION )
SET( CUDA_FOUND_BUT_LOW_VERSION 1 )
ELSEIF( CUDA_VERSION_MAJOR EQUAL OW_MIN_CUDA_MAJOR_VERSION )
IF( CUDA_VERSION_MINOR LESS OW_MIN_CUDA_MINOR_VERSION )
SET( CUDA_FOUND_BUT_LOW_VERSION 1 )
ENDIF()
ENDIF()
# abort incase invalid version of CUDA was found.
IF( CUDA_FOUND_BUT_LOW_VERSION )
MESSAGE( FATAL_ERROR "You have selected to use CUDA but an insufficent version: ${CUDA_VERSION_MAJOR}.${CUDA_VERSION_MINOR} was found, but ${OW_MIN_CUDA_MAJOR_VERSION}.${OW_MIN_CUDA_MINOR_VERSION} is required." )
ENDIF()
MESSAGE( STATUS "CUDA version: ${CUDA_VERSION_MAJOR}.${CUDA_VERSION_MINOR} was found." )
# set some common options
ADD_DEFINITIONS( -DCUDA_FOUND )
set( CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE ON )
set( BUILD_SHARED_LIBS ON )
set( CUDA_NVCC_FLAGS --compiler-options -fno-inline --ptxas-options=-v -arch=sm_12 )
set( CUDA_PROPAGATE_HOST_FLAGS OFF )
INCLUDE_DIRECTORIES( ${CUDA_TOOLKIT_INCLUDE} )
INCLUDE_DIRECTORIES( "${CUDA_SDK_ROOT_DIR}/common/inc" )
ENDIF( CUDA_FOUND )
ENDIF( OW_USE_CUDA )
# ---------------------------------------------------------------------------------------------------------------------------------------------------
#
# Toolbox Setup
#
# ---------------------------------------------------------------------------------------------------------------------------------------------------
# Toolbox mechanism. This is a nice possibility to turn on/off several modules. This can speed up build times if unneeded modules are turned off.
option( OW_MODULE_TOOLBOX_ALL "Turn all toolboxes on." OFF )
option( OW_MODULE_TOOLBOX_BASE "All the basic functionality modules. These modules are useful and needed for common visualizatuion tasks." ON )
option( OW_MODULE_TOOLBOX_EEG "EEG data processing and visualization." ON )
option( OW_MODULE_TOOLBOX_IMAGEPROCESSING "Image processing tools like filters." ON )
option( OW_MODULE_TOOLBOX_IO "Reader and Writer for several kinds of data." ON )
# this option is a simple list of all modules not in the above lists.
option( OW_MODULE_TOOLBOX_OTHERS "Advanced processing and visualization tools currently in development which have not been categorized to one of the other toolboxes." ON )
# Include needed lists
if( OW_MODULE_TOOLBOX_BASE OR OW_MODULE_TOOLBOX_ALL )
include( modules-base.toolbox )
endif( OW_MODULE_TOOLBOX_BASE OR OW_MODULE_TOOLBOX_ALL )
if( OW_MODULE_TOOLBOX_EEG OR OW_MODULE_TOOLBOX_ALL )
include( modules-eeg.toolbox )
endif( OW_MODULE_TOOLBOX_EEG OR OW_MODULE_TOOLBOX_ALL )
if( OW_MODULE_TOOLBOX_IMAGEPROCESSING OR OW_MODULE_TOOLBOX_ALL )
include( modules-imageprocessing.toolbox )
endif( OW_MODULE_TOOLBOX_IMAGEPROCESSING OR OW_MODULE_TOOLBOX_ALL )
if( OW_MODULE_TOOLBOX_IO OR OW_MODULE_TOOLBOX_ALL )
include( modules-io.toolbox )
endif( OW_MODULE_TOOLBOX_IO OR OW_MODULE_TOOLBOX_ALL )
if( OW_MODULE_TOOLBOX_OTHERS OR OW_MODULE_TOOLBOX_ALL )
include( modules-others.toolbox )
endif( OW_MODULE_TOOLBOX_OTHERS OR OW_MODULE_TOOLBOX_ALL )
# optional user toolbox which is not unter version control allowing all to only compile their modules needed.
include( modules-user.toolbox OPTIONAL )
#---------------------------------------------------------------------------
#
# Project: OpenWalnut ( http://www.openwalnut.org )
#
# Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
# For more information see http:#www.openwalnut.org/copying
#
# This file is part of OpenWalnut.
#
# OpenWalnut is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OpenWalnut is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with OpenWalnut. If not, see <http:#www.gnu.org/licenses/>.
#
#---------------------------------------------------------------------------
# ---------------------------------------------------------------------------------------------------------------------------------------------------
# Some common setup
# ---------------------------------------------------------------------------------------------------------------------------------------------------
# we use the directory name as module name
GET_FILENAME_COMPONENT( MODULE_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME )
# setup the target directories and names
SET( MODULE_TARGET_DIR ${OWModuleTargetDir}/${MODULE_NAME} )
SET( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${MODULE_TARGET_DIR} )
SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${MODULE_TARGET_DIR} )
SET( MODULE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} )
# -----------------------------------------------------------------------------------------------------------------------------------------------
# Add sources as target
# -----------------------------------------------------------------------------------------------------------------------------------------------
# Collect the compile-files for this target
COLLECT_COMPILE_FILES( "${MODULE_SOURCE_DIR}" TARGET_CPP_FILES TARGET_H_FILES TARGET_TEST_FILES )
# for cuda, we need to do some special stuff first
IF( CUDA_FOUND )
FILE( GLOB_RECURSE CUDA_SRC "*.cu" )
CUDA_ADD_LIBRARY( ${MODULE_NAME} SHARED ${TARGET_CPP_FILES} ${TARGET_H_FILES} ${CUDA_SRC} )
TARGET_LINK_LIBRARIES( ${MODULE_NAME} ${OWCoreName} ${CUDA_LIBRARIES} )
ELSE()
# Remove files that do including cuda stuff
LIST( REMOVE_ITEM TARGET_H_FILES ${CMAKE_CURRENT_SOURCE_DIR}/WCheckCudaError.h )
LIST( REMOVE_ITEM TARGET_H_FILES ${CMAKE_CURRENT_SOURCE_DIR}/WMDetTractClusteringCudaKernel.h )
LIST( REMOVE_ITEM TARGET_H_FILES ${CMAKE_CURRENT_SOURCE_DIR}/WMDetTractClusteringCudaInterface.h )
LIST( REMOVE_ITEM TARGET_CPP_FILES ${CMAKE_CURRENT_SOURCE_DIR}/WCheckCudaError.cpp )
LIST( REMOVE_ITEM TARGET_CPP_FILES ${CMAKE_CURRENT_SOURCE_DIR}/WMDetTractClusteringCudaInterface.cpp )
# Build the module without the cuda codes
ADD_LIBRARY( ${MODULE_NAME} SHARED ${TARGET_CPP_FILES} ${TARGET_H_FILES} )
TARGET_LINK_LIBRARIES( ${MODULE_NAME} ${OWCoreName} )
ENDIF()
# TODO(all): someone needs to explain this
IF(MSVC_IDE)
SET_TARGET_PROPERTIES( ${MODULE_NAME} PROPERTIES PREFIX "../")
ENDIF(MSVC_IDE)
# -----------------------------------------------------------------------------------------------------------------------------------------------
# Test Setup
# -----------------------------------------------------------------------------------------------------------------------------------------------
# Setup tests of this target
SETUP_TESTS( "${TARGET_TEST_FILES}" "${MODULE_NAME}" "${_MODULE_DEPENDENCIES}" )
# -----------------------------------------------------------------------------------------------------------------------------------------------
# Copy Shaders
# -----------------------------------------------------------------------------------------------------------------------------------------------
COLLECT_SHADER_FILES( ${MODULE_SOURCE_DIR} TARGET_GLSL_FILES )
SETUP_SHADERS( "${TARGET_GLSL_FILES}" "${MODULE_TARGET_DIR}/shaders" )
# -----------------------------------------------------------------------------------------------------------------------------------------------
# Style Checker
# -----------------------------------------------------------------------------------------------------------------------------------------------
# setup the stylechecker. Ignore the platform specific stuff.
SETUP_STYLECHECKER( "${MODULE_NAME}"
"${TARGET_CPP_FILES};${TARGET_H_FILES};${TARGET_TEST_FILES};${TARGET_GLSL_FILES}" # add all these files to the stylechecker
"${_MODULE_STYLE_EXCLUDES}" ) # exlude some ugly files
# mostly modules from our default whitelist
ADD_SUBDIRECTORY( arbitraryRois )
ADD_SUBDIRECTORY( colormapper )
ADD_SUBDIRECTORY( coordinateHUD )
ADD_SUBDIRECTORY( coordinateSystem )
ADD_SUBDIRECTORY( distanceMap )
ADD_SUBDIRECTORY( distanceMapIsosurface )
ADD_SUBDIRECTORY( fiberDisplay )
ADD_SUBDIRECTORY( functionalMRIViewer )
ADD_SUBDIRECTORY( gridRenderer )
ADD_SUBDIRECTORY( hud )
ADD_SUBDIRECTORY( imageSpaceLIC )
ADD_SUBDIRECTORY( isosurfaceRaytracer )
ADD_SUBDIRECTORY( lic )
ADD_SUBDIRECTORY( marchingCubes )
ADD_SUBDIRECTORY( navigationSlices )
# ADD_SUBDIRECTORY( overlayAtlas )
ADD_SUBDIRECTORY( paintTexture )
ADD_SUBDIRECTORY( superquadricGlyphs )
ADD_SUBDIRECTORY( template )
ADD_SUBDIRECTORY( triangleMeshRenderer )
ADD_SUBDIRECTORY( vectorPlot )
ADD_SUBDIRECTORY( voxelizer )
ADD_MODULE( arbitraryRois )
ADD_MODULE( colormapper )
ADD_MODULE( coordinateHUD )
ADD_MODULE( coordinateSystem )
ADD_MODULE( distanceMap )
ADD_MODULE( distanceMapIsosurface )
ADD_MODULE( fiberDisplay )
ADD_MODULE( functionalMRIViewer )
ADD_MODULE( gridRenderer )
ADD_MODULE( hud )
ADD_MODULE( imageSpaceLIC )
ADD_MODULE( isosurfaceRaytracer )
ADD_MODULE( lic "" ".*fibernavigator.*;.*fantom.*;" ) # lic uses some third party code
ADD_MODULE( marchingCubes )
ADD_MODULE( navigationSlices )
# ADD_MODULE( overlayAtlas )
ADD_MODULE( paintTexture )
ADD_MODULE( superquadricGlyphs )
ADD_MODULE( template ) # template has its own CMakeLists for demonstration purpose
ADD_MODULE( triangleMeshRenderer )
ADD_MODULE( vectorPlot )
ADD_MODULE( voxelizer )
ADD_SUBDIRECTORY( eegView )
ADD_MODULE( eegView )
ADD_SUBDIRECTORY( gaussFiltering )
ADD_SUBDIRECTORY( histogramEqualization )
ADD_SUBDIRECTORY( spatialDerivation )
ADD_MODULE( gaussFiltering )
ADD_MODULE( histogramEqualization )
ADD_MODULE( spatialDerivation )
ADD_SUBDIRECTORY( exportGeometry )
ADD_SUBDIRECTORY( readMesh )
ADD_SUBDIRECTORY( readSphericalHarmonics )
ADD_SUBDIRECTORY( writeDendrogram )
ADD_SUBDIRECTORY( writeMesh )
ADD_SUBDIRECTORY( writeNIfTI )
ADD_SUBDIRECTORY( writeTracts )
ADD_MODULE( exportGeometry )
ADD_MODULE( readMesh )
ADD_MODULE( readSphericalHarmonics )
ADD_MODULE( writeDendrogram )
ADD_MODULE( writeMesh )
ADD_MODULE( writeNIfTI )
ADD_MODULE( writeTracts )
ADD_SUBDIRECTORY( HARDIToSphericalHarmonics )
ADD_SUBDIRECTORY( calculateTensors )
ADD_SUBDIRECTORY( applyMask )
ADD_SUBDIRECTORY( arbitraryPlane )
ADD_SUBDIRECTORY( atlasCreator )
ADD_SUBDIRECTORY( atlasSurfaces )
ADD_SUBDIRECTORY( calculateGFA )
ADD_SUBDIRECTORY( clusterDisplay )
ADD_SUBDIRECTORY( clusterDisplayVoxels )
ADD_SUBDIRECTORY( clusterParamDisplay )
ADD_SUBDIRECTORY( clusterSlicer )
ADD_SUBDIRECTORY( contourTree )
ADD_SUBDIRECTORY( dataTypeConversion )
ADD_SUBDIRECTORY( datasetManipulator )
ADD_SUBDIRECTORY( datasetProfile )
ADD_SUBDIRECTORY( detTractClustering )
ADD_SUBDIRECTORY( detTractCulling )
ADD_SUBDIRECTORY( deterministicFTMori )
ADD_SUBDIRECTORY( directVolumeRendering )
ADD_SUBDIRECTORY( effectiveConnectivityCluster )
ADD_SUBDIRECTORY( eigenSystem )
ADD_SUBDIRECTORY( fiberDisplaySimple )
ADD_SUBDIRECTORY( fiberParameterColoring )
ADD_SUBDIRECTORY( fiberResampling )
ADD_SUBDIRECTORY( fiberSelection )
ADD_SUBDIRECTORY( fiberTransform )
ADD_SUBDIRECTORY( gaussProcesses )
ADD_SUBDIRECTORY( imageExtractor )
ADD_SUBDIRECTORY( lineGuidedSlice )
ADD_SUBDIRECTORY( probTractDisplay )
ADD_SUBDIRECTORY( probTractDisplaySP )
ADD_SUBDIRECTORY( scalarOperator )
ADD_SUBDIRECTORY( scalarSegmentation )
ADD_SUBDIRECTORY( splineSurface )
ADD_SUBDIRECTORY( subtractDataSetScalar )
ADD_SUBDIRECTORY( surfaceParameterAnimator )
ADD_SUBDIRECTORY( vectorOperator )
IF( OPENCL_FOUND )
ADD_SUBDIRECTORY( tensorGlyphs )
ENDIF()
ADD_MODULE( HARDIToSphericalHarmonics )
ADD_MODULE( calculateTensors )
ADD_MODULE( applyMask )
ADD_MODULE( arbitraryPlane )
ADD_MODULE( atlasCreator )
ADD_MODULE( atlasSurfaces )
ADD_MODULE( calculateGFA )
ADD_MODULE( clusterDisplay )
ADD_MODULE( clusterDisplayVoxels )
ADD_MODULE( clusterParamDisplay )
ADD_MODULE( clusterSlicer )
ADD_MODULE( contourTree )
ADD_MODULE( dataTypeConversion )
ADD_MODULE( datasetManipulator )
ADD_MODULE( datasetProfile )
ADD_MODULE( detTractClustering )
ADD_MODULE( detTractCulling )
ADD_MODULE( deterministicFTMori )
ADD_MODULE( directVolumeRendering )
ADD_MODULE( effectiveConnectivityCluster )
ADD_MODULE( eigenSystem )
ADD_MODULE( fiberDisplaySimple )
ADD_MODULE( fiberParameterColoring )
ADD_MODULE( fiberResampling )
ADD_MODULE( fiberSelection )
ADD_MODULE( fiberTransform )
ADD_MODULE( gaussProcesses )
ADD_MODULE( imageExtractor )
ADD_MODULE( lineGuidedSlice )
ADD_MODULE( probTractDisplay )
ADD_MODULE( probTractDisplaySP )
ADD_MODULE( scalarOperator )
ADD_MODULE( scalarSegmentation )
ADD_MODULE( splineSurface )
ADD_MODULE( subtractDataSetScalar )
ADD_MODULE( surfaceParameterAnimator )
ADD_MODULE( vectorOperator )
IF( Teem_FOUND )
ADD_SUBDIRECTORY( bermanTracking )
ADD_SUBDIRECTORY( teemGlyphs )
ENDIF()
ADD_MODULE( teemGlyphs ${Teem_LIBRARIES} )
ADD_MODULE( bermanTracking ${Teem_LIBRARIES} )
ENDIF( Teem_FOUND )
#---------------------------------------------------------------------------
#
# Project: OpenWalnut ( http://www.openwalnut.org )
#
# Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
# For more information see http:#www.openwalnut.org/copying
#
# This file is part of OpenWalnut.
#
# OpenWalnut is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OpenWalnut is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with OpenWalnut. If not, see <http:#www.gnu.org/licenses/>.
#
#---------------------------------------------------------------------------
# ---------------------------------------------------------------------------------------------------------------------------------------------------
# Some common setup
# ---------------------------------------------------------------------------------------------------------------------------------------------------
# we use the directory name as module name
GET_FILENAME_COMPONENT( MODULE_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME )
# ---------------------------------------------------------------------------------------------------------------------------------------------------
# Search own dependencies
# ---------------------------------------------------------------------------------------------------------------------------------------------------
# 1: FindPackage( LibYouNeed )
# 2: INCLUDE_DIRECTORIES( ${LIBYOUNEED_INCLUDE_DIR} )
# 3: LINK_DIRECTORIES( ${LIBYOUNEED_LIBRARY_DIRS} )
# 4: Add ${LIBYOUNEED_LIBRARY} as _MODULE_DEPENDENCIES parameter to SETUP_MODULE
# ---------------------------------------------------------------------------------------------------------------------------------------------------
# Setup for compilation
# ---------------------------------------------------------------------------------------------------------------------------------------------------
# Let this function do the job. It sets up tests and copies shaders automatically. It additionally configures the stylecheck mechanism for this
# module.
SETUP_MODULE( ${MODULE_NAME} # name of the module
"${CMAKE_CURRENT_SOURCE_DIR}" # where to find the source ${CMAKE_CURRENT_SOURCE_DIR} is a good idea here mostly
"" # does your module need additional libs to compile?
"" # do you want to exlucde files from stylechecking? (externals for example)
)
#---------------------------------------------------------------------------
#
# Project: OpenWalnut ( http://www.openwalnut.org )
#
# Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
# For more information see http:#www.openwalnut.org/copying
#
# This file is part of OpenWalnut.
#
# OpenWalnut is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OpenWalnut is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with OpenWalnut. If not, see <http:#www.gnu.org/licenses/>.
#
#---------------------------------------------------------------------------
# Automatically add a module. Do not use this function if your module nees additional dependencies or similar. For more flexibility, use your own
# CMakeLists in combination with the SETUP_MODULE function. The Code for the module is searched in ${CMAKE_CURRENT_SOURCE_DIR}/${_MODULE_NAME}.
# It loads the CMakeLists in the module dir if there is any.
# _MODULE_NAME the name of the module
# Optional second Parameter: list of additional dependencies
# Optional third Parameter: list of style-excludes as regexp.
FUNCTION( ADD_MODULE _MODULE_NAME )
SET( MODULE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/${_MODULE_NAME} )
# is there a CMakeLists.txt? If yes, use it.
IF( EXISTS ${MODULE_SOURCE_DIR}/CMakeLists.txt )
ADD_SUBDIRECTORY( ${_MODULE_NAME} )
RETURN()
ENDIF()
# Optional second parameter: style exclusion list
SET( _DEPENDENCIES ${ARGV1} )
SET( _EXCLUDES ${ARGV2} )
# -----------------------------------------------------------------------------------------------------------------------------------------------
# Setup for compilation
# -----------------------------------------------------------------------------------------------------------------------------------------------
# Let this function do the job. It sets up tests and copies shaders automatically. It additionally configures the stylecheck mechanism for this
# module.
SETUP_MODULE( ${_MODULE_NAME} # name of the module
"${MODULE_SOURCE_DIR}"
"${_DEPENDENCIES}"
"${_EXCLUDES}"
)
ENDFUNCTION( ADD_MODULE )
# Comfortably setup a module for compilation. This automatically handles the target creation, stylecheck and tests (with fixtures).
# _MODULE_NAME the name of the module
# _MODULE_SOURCE_DIR where to finx the code for the module
# _MODULE_DEPENDENCIES additional dependencies can be added here
# _MODULE_STYLE_EXCLUDES exclude files from stylecheck matching these regular expressions (list)
FUNCTION( SETUP_MODULE _MODULE_NAME _MODULE_SOURCE_DIR _MODULE_DEPENDENCIES _MODULE_STYLE_EXCLUDES )
# -----------------------------------------------------------------------------------------------------------------------------------------------
# Some common setup
# -----------------------------------------------------------------------------------------------------------------------------------------------
# setup the target directories and names
SET( MODULE_NAME ${_MODULE_NAME} )
SET( MODULE_TARGET_DIR ${OWModuleTargetDir}/${MODULE_NAME} )
SET( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${MODULE_TARGET_DIR} )
SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${MODULE_TARGET_DIR} )
SET( MODULE_SOURCE_DIR ${_MODULE_SOURCE_DIR} )
# -----------------------------------------------------------------------------------------------------------------------------------------------
# Add sources as target
# -----------------------------------------------------------------------------------------------------------------------------------------------
# Collect the compile-files for this target
COLLECT_COMPILE_FILES( "${MODULE_SOURCE_DIR}" TARGET_CPP_FILES TARGET_H_FILES TARGET_TEST_FILES )
# Setup the target
ADD_LIBRARY( ${MODULE_NAME} SHARED ${TARGET_CPP_FILES} ${TARGET_H_FILES} )
TARGET_LINK_LIBRARIES( ${MODULE_NAME} ${OWCoreName} ${Boost_LIBRARIES} ${OPENGL_gl_LIBRARY} ${OPENSCENEGRAPH_LIBRARIES} ${_MODULE_DEPENDENCIES} )
# TODO(all): someone needs to explain this
IF(MSVC_IDE)
SET_TARGET_PROPERTIES( ${MODULE_NAME} PROPERTIES PREFIX "../")
ENDIF(MSVC_IDE)
# -----------------------------------------------------------------------------------------------------------------------------------------------
# Test Setup
# -----------------------------------------------------------------------------------------------------------------------------------------------
# Setup tests of this target
SETUP_TESTS( "${TARGET_TEST_FILES}" "${MODULE_NAME}" "${_MODULE_DEPENDENCIES}" )
# -----------------------------------------------------------------------------------------------------------------------------------------------
# Copy Shaders
# -----------------------------------------------------------------------------------------------------------------------------------------------
COLLECT_SHADER_FILES( ${MODULE_SOURCE_DIR} TARGET_GLSL_FILES )
SETUP_SHADERS( "${TARGET_GLSL_FILES}" "${MODULE_TARGET_DIR}/shaders" )
# -----------------------------------------------------------------------------------------------------------------------------------------------
# Style Checker
# -----------------------------------------------------------------------------------------------------------------------------------------------
# setup the stylechecker. Ignore the platform specific stuff.
SETUP_STYLECHECKER( "${MODULE_NAME}"
"${TARGET_CPP_FILES};${TARGET_H_FILES};${TARGET_TEST_FILES};${TARGET_GLSL_FILES}" # add all these files to the stylechecker
"${_MODULE_STYLE_EXCLUDES}" ) # exlude some ugly files
ENDFUNCTION( SETUP_MODULE )
......@@ -65,7 +65,7 @@ FUNCTION( SETUP_TESTS _TEST_FILES _TEST_TARGET )
# Abort if no tests are present
LIST( LENGTH _TEST_FILES TestFileListLength )
IF( ${TestFileListLength} STREQUAL "0" )
MESSAGE( STATUS "No tests for target ${_TEST_TARGET}. You should always consider unit testing!" )
# MESSAGE( STATUS "No tests for target ${_TEST_TARGET}. You should always consider unit testing!" )
RETURN()
ENDIF()
......@@ -116,24 +116,28 @@ FUNCTION( SETUP_TESTS _TEST_FILES _TEST_TARGET )
ENDIF( IsFixture )
ENDFOREACH( fixture )
# the list may contain duplicates
LIST( REMOVE_DUPLICATES FixturePaths )
# -------------------------------------------------------------------------------------------------------------------------------------------
# Create copy target for each fixture directory
# -------------------------------------------------------------------------------------------------------------------------------------------
# for each fixture, copy to build dir
FOREACH( FixtureDir ${FixturePaths} )
# we need a unique name for each fixture dir as target
STRING( REGEX REPLACE "[^A-Za-z0-9]" "" FixtureDirEscaped "${FixtureDir}" )
# finally, create the copy target
ADD_CUSTOM_TARGET( ${_TEST_TARGET}_CopyFixtures_${FixtureDirEscaped}
COMMAND ${CMAKE_COMMAND} -E copy_directory "${FixtureDir}" "${FixtureTargetDirectory}"
COMMENT "Copy fixtures of ${_TEST_TARGET} from ${FixtureDir}."
)
ADD_DEPENDENCIES( ${_TEST_TARGET} ${_TEST_TARGET}_CopyFixtures_${FixtureDirEscaped} )
ENDFOREACH( FixtureDir )
# REMOVE_DUPLICATES throws an error if list is empty. So we check this here
LIST( LENGTH FixturePaths ListLength )
IF( NOT ${ListLength} STREQUAL "0" )
# the list may contain duplicates
LIST( REMOVE_DUPLICATES FixturePaths )
# ---------------------------------------------------------------------------------------------------------------------------------------
# Create copy target for each fixture directory
# ---------------------------------------------------------------------------------------------------------------------------------------
# for each fixture, copy to build dir
FOREACH( FixtureDir ${FixturePaths} )
# we need a unique name for each fixture dir as target
STRING( REGEX REPLACE "[^A-Za-z0-9]" "" FixtureDirEscaped "${FixtureDir}" )
# finally, create the copy target
ADD_CUSTOM_TARGET( ${_TEST_TARGET}_CopyFixtures_${FixtureDirEscaped}
COMMAND ${CMAKE_COMMAND} -E copy_directory "${FixtureDir}" "${FixtureTargetDirectory}"
COMMENT "Copy fixtures of ${_TEST_TARGET} from ${FixtureDir}."
)
ADD_DEPENDENCIES( ${_TEST_TARGET} ${_TEST_TARGET}_CopyFixtures_${FixtureDirEscaped} )
ENDFOREACH( FixtureDir )
ENDIF()
ENDIF( OW_COMPILE_TESTS )