1
#---------------------------------------------------------------------------
3
# Project: OpenWalnut ( http://www.openwalnut.org )
5
# Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6
# For more information see http:#www.openwalnut.org/copying
8
# This file is part of OpenWalnut.
10
# OpenWalnut is free software: you can redistribute it and/or modify
11
# it under the terms of the GNU Lesser General Public License as published by
12
# the Free Software Foundation, either version 3 of the License, or
13
# (at your option) any later version.
15
# OpenWalnut is distributed in the hope that it will be useful,
16
# but WITHOUT ANY WARRANTY; without even the implied warranty of
17
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
# GNU Lesser General Public License for more details.
20
# You should have received a copy of the GNU Lesser General Public License
21
# along with OpenWalnut. If not, see <http:#www.gnu.org/licenses/>.
23
#---------------------------------------------------------------------------
25
# Automatically add a module. Do not use this function if your module nees additional dependencies or similar. For more flexibility, use your own
26
# CMakeLists in combination with the SETUP_MODULE function. The Code for the module is searched in ${CMAKE_CURRENT_SOURCE_DIR}/${_MODULE_NAME}.
27
# It loads the CMakeLists in the module dir if there is any.
28
# _MODULE_NAME the name of the module
29
# Optional second Parameter: list of additional dependencies
30
# Optional third Parameter: list of style-excludes as regexp.
31
FUNCTION( ADD_MODULE _MODULE_NAME )
32
SET( MODULE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/${_MODULE_NAME} )
34
# is there a CMakeLists.txt? If yes, use it.
35
IF( EXISTS ${MODULE_SOURCE_DIR}/CMakeLists.txt )
36
ADD_SUBDIRECTORY( ${_MODULE_NAME} )
40
# Optional second parameter: style exclusion list
41
SET( _DEPENDENCIES ${ARGV1} )
42
SET( _EXCLUDES ${ARGV2} )
44
# -----------------------------------------------------------------------------------------------------------------------------------------------
45
# Setup for compilation
46
# -----------------------------------------------------------------------------------------------------------------------------------------------
48
# Let this function do the job. It sets up tests and copies shaders automatically. It additionally configures the stylecheck mechanism for this
50
SETUP_MODULE( ${_MODULE_NAME} # name of the module
51
"${MODULE_SOURCE_DIR}"
55
ENDFUNCTION( ADD_MODULE )
57
# Comfortably setup a module for compilation. This automatically handles the target creation, stylecheck and tests (with fixtures).
58
# _MODULE_NAME the name of the module
59
# _MODULE_SOURCE_DIR where to finx the code for the module
60
# _MODULE_DEPENDENCIES additional dependencies can be added here. This is a list. Use ";" to add multiple additional dependencies
61
# _MODULE_STYLE_EXCLUDES exclude files from stylecheck matching these regular expressions (list)
62
FUNCTION( SETUP_MODULE _MODULE_NAME _MODULE_SOURCE_DIR _MODULE_DEPENDENCIES _MODULE_STYLE_EXCLUDES )
63
# -----------------------------------------------------------------------------------------------------------------------------------------------
65
# -----------------------------------------------------------------------------------------------------------------------------------------------
67
# setup the target directories and names
68
SET( MODULE_NAME ${_MODULE_NAME} )
69
SET( MODULE_TARGET_DIR_RELATIVE ${OW_MODULE_DIR_RELATIVE}/${MODULE_NAME} )
70
SET( MODULE_TARGET_DIR ${PROJECT_BINARY_DIR}/${MODULE_TARGET_DIR_RELATIVE} )
71
SET( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${MODULE_TARGET_DIR} )
72
SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${MODULE_TARGET_DIR} )
73
SET( MODULE_SOURCE_DIR ${_MODULE_SOURCE_DIR} )
75
# -----------------------------------------------------------------------------------------------------------------------------------------------
76
# Add sources as target
77
# -----------------------------------------------------------------------------------------------------------------------------------------------
79
# Collect the compile-files for this target
80
COLLECT_COMPILE_FILES( "${MODULE_SOURCE_DIR}" TARGET_CPP_FILES TARGET_H_FILES TARGET_TEST_FILES )
83
ADD_LIBRARY( ${MODULE_NAME} SHARED ${TARGET_CPP_FILES} ${TARGET_H_FILES} )
84
TARGET_LINK_LIBRARIES( ${MODULE_NAME} ${OWCoreName} ${Boost_LIBRARIES} ${OPENGL_gl_LIBRARY} ${OPENSCENEGRAPH_LIBRARIES} ${_MODULE_DEPENDENCIES} )
86
# Set the version of the library.
87
SET_TARGET_PROPERTIES( ${MODULE_NAME} PROPERTIES
88
VERSION ${OW_LIB_VERSION}
89
SOVERSION ${OW_SOVERSION}
92
# Do not forget the install targets
93
SETUP_LIB_INSTALL( ${MODULE_NAME} ${MODULE_TARGET_DIR_RELATIVE} "MODULES" )
95
# TODO(all): someone needs to explain this
97
SET_TARGET_PROPERTIES( ${MODULE_NAME} PROPERTIES PREFIX "../")
100
# -----------------------------------------------------------------------------------------------------------------------------------------------
102
# -----------------------------------------------------------------------------------------------------------------------------------------------
104
# Setup tests of this target
105
SETUP_TESTS( "${TARGET_TEST_FILES}" "${MODULE_NAME}" "${_MODULE_DEPENDENCIES}" )
107
# -----------------------------------------------------------------------------------------------------------------------------------------------
109
# -----------------------------------------------------------------------------------------------------------------------------------------------
111
COLLECT_SHADER_FILES( ${MODULE_SOURCE_DIR} TARGET_GLSL_FILES )
112
SETUP_SHADERS( "${TARGET_GLSL_FILES}" "${MODULE_TARGET_DIR_RELATIVE}/shaders" "MODULES" )
114
# -----------------------------------------------------------------------------------------------------------------------------------------------
116
# -----------------------------------------------------------------------------------------------------------------------------------------------
118
# setup the stylechecker. Ignore the platform specific stuff.
119
SETUP_STYLECHECKER( "${MODULE_NAME}"
120
"${TARGET_CPP_FILES};${TARGET_H_FILES};${TARGET_TEST_FILES};${TARGET_GLSL_FILES}" # add all these files to the stylechecker
121
"${_MODULE_STYLE_EXCLUDES}" ) # exlude some ugly files
123
ENDFUNCTION( SETUP_MODULE )