CMakeLists.txt 8.7 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
#---------------------------------------------------------------------------
#
# 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/>.
#
#---------------------------------------------------------------------------

25 26 27 28
# ---------------------------------------------------------------------------------------------------------------------------------------------------
# Some common setup
# ---------------------------------------------------------------------------------------------------------------------------------------------------

29 30
SET( LibName ${OWCoreName} )

31 32 33 34 35 36 37 38 39 40 41
# Set the prefix and suffix of dynamically loadable modules to match
# CMAKEs naming of them. The quotes are necessary so the shell doesn't mess
# with these defines. Unfortunately, the Visual Studio has problems handling
# the quotes on the command line. WSharedLib::getSystemPrefix and
# getSystemSuffix hard codes the right strings for VC.
# Maybe you have to spend another 500 bucks to have your VC support quotes.
IF( NOT CMAKE_GENERATOR MATCHES "Visual Studio" )
    ADD_DEFINITIONS( '-DW_LIB_PREFIX="${CMAKE_SHARED_LIBRARY_PREFIX}"' )
    ADD_DEFINITIONS( '-DW_LIB_SUFFIX="${CMAKE_SHARED_LIBRARY_SUFFIX}"' )
ENDIF()

42 43 44 45
# ---------------------------------------------------------------------------------------------------------------------------------------------------
# Add sources as target
# ---------------------------------------------------------------------------------------------------------------------------------------------------

46 47
# Collect the compile-files for this target
COLLECT_COMPILE_FILES( "${CMAKE_CURRENT_SOURCE_DIR}" TARGET_CPP_FILES TARGET_H_FILES TARGET_TEST_FILES )
48

49
# Setup the target
50
ADD_LIBRARY( ${LibName} SHARED ${TARGET_CPP_FILES} ${TARGET_H_FILES} ${OW_VERSION_HEADER} )
51
TARGET_LINK_LIBRARIES( ${LibName} ${Boost_LIBRARIES} ${CMAKE_DL_LIBS} ${OPENGL_gl_LIBRARY} ${OPENSCENEGRAPH_LIBRARIES}
52
                     )
53

54 55 56 57
# Tell CMake that someone creates this file for us. See doc of SETUP_VERSION_HEADER in BuildUtils.cmake for details why this is needed.
# NOTE: this needs to be placed AFTER ADD_EXECUTABLE or ADD_LIBRARY
SETUP_USE_VERSION_HEADER( ${LibName} )

58
# Set the version of the library.
59
SET_TARGET_PROPERTIES( ${LibName} PROPERTIES 
60
                       VERSION ${OW_LIB_VERSION} 
61
                       SOVERSION ${OW_SOVERSION}
62
)
63

64
# Do not forget the install targets
65
SETUP_LIB_INSTALL( ${LibName} ${OW_LIBRARY_DIR_RELATIVE} "CORE" )
66 67 68

# Core contains the headers which are needed for any developer release. Install them.
# NOTE: do not use ${TARGET_H_FILES}. The command requires a list
69
SETUP_DEV_INSTALL( ${LibName} ${OW_LIBRARY_DIR_RELATIVE} TARGET_H_FILES "include/openwalnut/core" "CORE_DEV" )
70

71 72 73
# The core does also provide some nice pkg-config file. Set this up and configure it to contain the correct install prefix
SETUP_CONFIGURED_FILE( "core-dev" "lib/pkgconfig/openwalnut.pc" "CORE_DEV" )

74 75 76
# ---------------------------------------------------------------------------------------------------------------------------------------------------
# Test Setup
# ---------------------------------------------------------------------------------------------------------------------------------------------------
77

78
# Setup tests of this target
79
SETUP_TESTS( "${TARGET_TEST_FILES}" "${LibName}" "" )
80

81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
# ---------------------------------------------------------------------------------------------------------------------------------------------------
# Doxygen Release documentation
# ---------------------------------------------------------------------------------------------------------------------------------------------------

# NOTE: this full documentation also includes call/caller graphs, colaboration graphs and nicer inheritance graphs
# but needs "dot" from graphviz to render them.
SET( DEVDOC_DIR "${PROJECT_SOURCE_DIR}/../doc/core/html" )
ADD_CUSTOM_TARGET( core_devdoc
                   COMMAND doxygen ${PROJECT_SOURCE_DIR}/../doc/core/doxygenConfig
                   COMMAND chmod -R g+r ${DEVDOC_DIR}
                   WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/..
                   COMMENT "Build verbose doxygen documentation for core"
                   VERBATIM
                 )

96 97 98 99 100
# ---------------------------------------------------------------------------------------------------------------------------------------------------
# Copy local resources
# ---------------------------------------------------------------------------------------------------------------------------------------------------

# copy our own resources
101 102 103 104 105 106 107
IF( NOT OW_PACKAGE_NOCOPY_COREFONTS )
    SETUP_RESOURCES( "core" "CORE" )
ELSE()
    # This is a hack which is quite debian specific. We do this here to avoid font duplicates since the ttf-liberation fonts are already
    # available on Debian. If you need to modify this for another packaging thingy, please let me know (ebaum@informatik.uni-leipzig.d). We then
    # should find a generic solution.
    IF( OW_PACKAGE_PACKAGER STREQUAL "deb" )
108
        INSTALL( CODE "MESSAGE( \"INSTALL: Symlinking fonts to \${CMAKE_INSTALL_PREFIX}/share/openwalnut/fonts.\" )"
109
                COMPONENT "CORE" )
110
        INSTALL( CODE "EXECUTE_PROCESS( COMMAND ${CMAKE_COMMAND} -E make_directory \${CMAKE_INSTALL_PREFIX}/share/openwalnut/fonts )"
111
                COMPONENT "CORE" ) 
112
        INSTALL( CODE "EXECUTE_PROCESS( COMMAND ${CMAKE_COMMAND} -E create_symlink /usr/share/fonts/truetype/ttf-liberation/LiberationMono-Bold.ttf \${CMAKE_INSTALL_PREFIX}/share/openwalnut/fonts/arial.ttf )"
113
                COMPONENT "CORE" )
114
        INSTALL( CODE "EXECUTE_PROCESS( COMMAND ${CMAKE_COMMAND} -E create_symlink /usr/share/fonts/truetype/ttf-liberation/LiberationMono-Bold.ttf \${CMAKE_INSTALL_PREFIX}/share/openwalnut/fonts/Bold.ttf )"
115
                COMPONENT "CORE" )
116
        INSTALL( CODE "EXECUTE_PROCESS( COMMAND ${CMAKE_COMMAND} -E create_symlink /usr/share/fonts/truetype/ttf-liberation/LiberationMono-Italic.ttf \${CMAKE_INSTALL_PREFIX}/share/openwalnut/fonts/Italic.ttf )"
117
                COMPONENT "CORE" )
118
        INSTALL( CODE "EXECUTE_PROCESS( COMMAND ${CMAKE_COMMAND} -E create_symlink /usr/share/fonts/truetype/ttf-liberation/LiberationMono-Regular.ttf \${CMAKE_INSTALL_PREFIX}/share/openwalnut/fonts/Regular.ttf )"
119 120 121 122 123
                COMPONENT "CORE" )
    ELSE()
        MESSAGE( STATUS "Warning: You enabled \"OW_PACKAGE_NOCOPY_COREFONTS\" but packager unknown." ) 
    ENDIF()
ENDIF()
124 125

# where to put doc files?
126 127 128
# NOTE: the doc path should match the SONAME of lib. Use this command to query a proper name:
# objdump -p libopenwalnut.so | sed -n -e's/^[[:space:]]*SONAME[[:space:]]*//p' | sed -e's/\([0-9]\)\.so\./\1-/; s/\.so\.//'
SET( OW_DOC_DIR_RELATIVE "share/doc/libopenwalnut1" )
129 130
SETUP_COMMON_DOC( ${OW_DOC_DIR_RELATIVE} "CORE" )

131 132 133 134
# Also add an install target for this
INSTALL( DIRECTORY ${DEVDOC_DIR} 
         DESTINATION ${OW_DOC_DIR_RELATIVE}
         COMPONENT "CORE_DOC"
135
         OPTIONAL
136 137
       )

138
# ---------------------------------------------------------------------------------------------------------------------------------------------------
139
# Copy Shaders
140
# ---------------------------------------------------------------------------------------------------------------------------------------------------
141

142
COLLECT_SHADER_FILES( ${CMAKE_CURRENT_SOURCE_DIR} TARGET_GLSL_FILES )
143
SETUP_SHADERS( "${TARGET_GLSL_FILES}" "${OW_SHARE_DIR_RELATIVE}/shaders" "CORE" )
144 145 146 147

# ---------------------------------------------------------------------------------------------------------------------------------------------------
# Style Checker
# ---------------------------------------------------------------------------------------------------------------------------------------------------
148

149 150 151
# setup the stylechecker. Ignore the platform specific stuff.
SETUP_STYLECHECKER( "${LibName}"
                    "${TARGET_CPP_FILES};${TARGET_H_FILES};${TARGET_TEST_FILES};${TARGET_GLSL_FILES}"  # add all these files to the stylechecker
152
                    "" )                                        # exlude some ugly files
153