~ubuntu-branches/ubuntu/raring/openwalnut/raring

« back to all changes in this revision

Viewing changes to tools/cmake/BuildModuleUtils.cmake

  • Committer: Package Import Robot
  • Author(s): Sebastian Eichelbaum
  • Date: 2012-12-12 11:26:32 UTC
  • mfrom: (3.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20121212112632-xhiuwkxuz5h0idkh
Tags: 1.3.1+hg5849-1
* Minor changes compared to 1.3.0 but included several bug fixes.
* See http://www.openwalnut.org/versions/4

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#---------------------------------------------------------------------------
2
 
#
3
 
# Project: OpenWalnut ( http://www.openwalnut.org )
4
 
#
5
 
# Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6
 
# For more information see http:#www.openwalnut.org/copying
7
 
#
8
 
# This file is part of OpenWalnut.
9
 
#
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.
14
 
#
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.
19
 
#
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/>.
22
 
#
23
 
#---------------------------------------------------------------------------
24
 
 
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} )
33
 
 
34
 
    # is there a CMakeLists.txt? If yes, use it.
35
 
    IF( EXISTS ${MODULE_SOURCE_DIR}/CMakeLists.txt )
36
 
        ADD_SUBDIRECTORY( ${_MODULE_NAME} )
37
 
        RETURN()
38
 
    ENDIF()
39
 
 
40
 
    # Optional second parameter: style exclusion list
41
 
    SET( _DEPENDENCIES ${ARGV1} )
42
 
    SET( _EXCLUDES ${ARGV2} )
43
 
 
44
 
    # -----------------------------------------------------------------------------------------------------------------------------------------------
45
 
    # Setup for compilation
46
 
    # -----------------------------------------------------------------------------------------------------------------------------------------------
47
 
 
48
 
    # Let this function do the job. It sets up tests and copies shaders automatically. It additionally configures the stylecheck mechanism for this
49
 
    # module.
50
 
    SETUP_MODULE( ${_MODULE_NAME}                # name of the module
51
 
                 "${MODULE_SOURCE_DIR}"
52
 
                 "${_DEPENDENCIES}"
53
 
                 "${_EXCLUDES}"
54
 
    )
55
 
ENDFUNCTION( ADD_MODULE )
56
 
 
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
 
    # -----------------------------------------------------------------------------------------------------------------------------------------------
64
 
    # Some common setup
65
 
    # -----------------------------------------------------------------------------------------------------------------------------------------------
66
 
 
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} )
74
 
 
75
 
    # -----------------------------------------------------------------------------------------------------------------------------------------------
76
 
    # Add sources as target
77
 
    # -----------------------------------------------------------------------------------------------------------------------------------------------
78
 
 
79
 
    # Collect the compile-files for this target
80
 
    COLLECT_COMPILE_FILES( "${MODULE_SOURCE_DIR}" TARGET_CPP_FILES TARGET_H_FILES TARGET_TEST_FILES )
81
 
 
82
 
    # Setup the target
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} )
85
 
 
86
 
    # Set the version of the library.
87
 
    SET_TARGET_PROPERTIES( ${MODULE_NAME} PROPERTIES
88
 
        VERSION ${OW_LIB_VERSION}
89
 
        SOVERSION ${OW_SOVERSION}
90
 
    )
91
 
 
92
 
    # Do not forget the install targets
93
 
    SETUP_LIB_INSTALL( ${MODULE_NAME} ${MODULE_TARGET_DIR_RELATIVE} "MODULES" )
94
 
 
95
 
    # TODO(all): someone needs to explain this
96
 
    IF(MSVC_IDE)
97
 
        SET_TARGET_PROPERTIES( ${MODULE_NAME} PROPERTIES PREFIX "../")
98
 
    ENDIF(MSVC_IDE)
99
 
 
100
 
    # -----------------------------------------------------------------------------------------------------------------------------------------------
101
 
    # Test Setup
102
 
    # -----------------------------------------------------------------------------------------------------------------------------------------------
103
 
 
104
 
    # Setup tests of this target
105
 
    SETUP_TESTS( "${TARGET_TEST_FILES}" "${MODULE_NAME}" "${_MODULE_DEPENDENCIES}" )
106
 
 
107
 
    # -----------------------------------------------------------------------------------------------------------------------------------------------
108
 
    # Copy Shaders
109
 
    # -----------------------------------------------------------------------------------------------------------------------------------------------
110
 
 
111
 
    COLLECT_SHADER_FILES( ${MODULE_SOURCE_DIR} TARGET_GLSL_FILES )
112
 
    SETUP_SHADERS( "${TARGET_GLSL_FILES}" "${MODULE_TARGET_DIR_RELATIVE}/shaders" "MODULES" )
113
 
 
114
 
    # -----------------------------------------------------------------------------------------------------------------------------------------------
115
 
    # Style Checker
116
 
    # -----------------------------------------------------------------------------------------------------------------------------------------------
117
 
 
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
122
 
 
123
 
ENDFUNCTION( SETUP_MODULE )
124