Commit 178cffbe authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[ADD] - added resource copy install targets. Next step: install targets for libs and bins

parent 0a3dffb6
......@@ -41,12 +41,9 @@ LIST( APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../tools/CMakeModules )
# here, we have certain utilities. For example ASSERT_GE_VERSION which ensures a specific minimum version
INCLUDE( ${PROJECT_SOURCE_DIR}/../tools/CMakeModules/Utils.cmake )
# mimic layout of install dir for build:
SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin )
SET( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib )
SET( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib )
SET( OW_CONFIG_DIR ${PROJECT_BINARY_DIR}/etc/OpenWalnut )
SET( OW_SHARE_DIR ${PROJECT_BINARY_DIR}/share/OpenWalnut )
# These scripts 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 )
# CMAKE automatism to select static vs. shared building:
IF( NOT CMAKE_GENERATOR MATCHES "Visual Studio" )
......@@ -77,6 +74,32 @@ IF( NOT cmake_build_type_tolower STREQUAL "debug" AND
MESSAGE( SEND_ERROR "Unknown build type \"${CMAKE_BUILD_TYPE}\". Allowed values are Debug, Release, RelWithDebInfo and \"\" (case-insensitive).")
ENDIF()
# ---------------------------------------------------------------------------------------------------------------------------------------------------
#
# Install/Target-dir Options
# - NOTE: in our setup, build dir structure and install structure are the same
#
# ---------------------------------------------------------------------------------------------------------------------------------------------------
# mimic layout of install dir for build:
SET( OW_CONFIG_DIR_RELATIVE "etc/OpenWalnut" )
SET( OW_CONFIG_DIR ${PROJECT_BINARY_DIR}/${OW_CONFIG_DIR_RELATIVE} )
SET( OW_SHARE_DIR_RELATIVE "share/OpenWalnut" )
SET( OW_SHARE_DIR ${PROJECT_BINARY_DIR}/${OW_SHARE_DIR_RELATIVE} )
SET( OW_RUNTIME_DIR_RELATIVE "bin" )
SET( OW_RUNTIME_DIR ${PROJECT_BINARY_DIR}/${OW_RUNTIME_DIR_RELATIVE} )
SET( OW_LIBRARY_DIR_RELATIVE "lib" )
SET( OW_LIBRARY_DIR ${PROJECT_BINARY_DIR}/${OW_LIBRARY_DIR_RELATIVE} )
SET( OW_ARCHIVE_DIR_RELATIVE "lib" )
SET( OW_ARCHIVE_DIR ${PROJECT_BINARY_DIR}/${OW_ARCHIVE_DIR_RELATIVE} )
SET( OW_MODULE_DIR_RELATIVE "lib/OpenWalnut" )
SET( OW_MODULE_DIR ${PROJECT_BINARY_DIR}/${OW_MODULE_DIR_RELATIVE} )
# set our paths for install targets
SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${OW_RUNTIME_DIR} )
SET( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${OW_LIBRARY_DIR} )
SET( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${OW_ARCHIVE_DIR} )
# ---------------------------------------------------------------------------------------------------------------------------------------------------
#
# Compilation Options
......@@ -234,13 +257,8 @@ ADD_CUSTOM_TARGET( vtest
#
# ---------------------------------------------------------------------------------------------------------------------------------------------------
# as all the resources with the correct directory structure reside in ../resources, this target is very easy to handle
SET( ResourcesPath "${PROJECT_SOURCE_DIR}/../resources" )
ADD_CUSTOM_TARGET( ResourceConfiguration
ALL
COMMAND ${CMAKE_COMMAND} -E copy_directory "${ResourcesPath}" "${PROJECT_BINARY_DIR}/"
COMMENT "Copying resources to build directory"
)
# Setup everything in ../resources
SETUP_RESOURCES()
# this is done once -> create one default walnut.cfg
IF( NOT EXISTS ${OW_CONFIG_DIR}/walnut.cfg )
......@@ -343,10 +361,6 @@ ADD_CUSTOM_TARGET( many
#
# ---------------------------------------------------------------------------------------------------------------------------------------------------
# These scripts 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 )
INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/ext )
......@@ -384,9 +398,6 @@ ADD_SUBDIRECTORY( qt4gui )
# -----------------------------------------------------------------------------------------------------------------------------------------------
# Modules
# where to put the modules by default?
SET( OWModuleTargetDir ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/OpenWalnut )
# build modules
ADD_SUBDIRECTORY( modules )
......@@ -396,3 +407,4 @@ ADD_SUBDIRECTORY( modules )
#
# ---------------------------------------------------------------------------------------------------------------------------------------------------
......@@ -64,7 +64,7 @@ SETUP_TESTS( "${TARGET_TEST_FILES}" "${LibName}" "" )
# ---------------------------------------------------------------------------------------------------------------------------------------------------
COLLECT_SHADER_FILES( ${CMAKE_CURRENT_SOURCE_DIR} TARGET_GLSL_FILES )
SETUP_SHADERS( "${TARGET_GLSL_FILES}" "${OW_SHARE_DIR}/shaders" )
SETUP_SHADERS( "${TARGET_GLSL_FILES}" "${OW_SHARE_DIR_RELATIVE}/shaders" )
# ---------------------------------------------------------------------------------------------------------------------------------------------------
# Style Checker
......@@ -74,3 +74,4 @@ SETUP_SHADERS( "${TARGET_GLSL_FILES}" "${OW_SHARE_DIR}/shaders" )
SETUP_STYLECHECKER( "${LibName}"
"${TARGET_CPP_FILES};${TARGET_H_FILES};${TARGET_TEST_FILES};${TARGET_GLSL_FILES}" # add all these files to the stylechecker
".*platformDependent\\/visualStudio\\/.*" ) # exlude some ugly files
......@@ -32,7 +32,6 @@
#include <boost/math/special_functions/spherical_harmonic.hpp>
#include <boost/thread/thread.hpp>
#include "HARDIToSphericalHarmonics.xpm"
#include "core/common/WLimits.h"
#include "core/common/WAssert.h"
......@@ -52,6 +51,7 @@
#include "WSphericalHarmonicsCoefficientsThread.h"
#include "WMHARDIToSphericalHarmonics.h"
#include "HARDIToSphericalHarmonics.xpm"
// This line is needed by the module loader to actually find your module.
W_LOADABLE_MODULE( WMHARDIToSphericalHarmonics )
......
......@@ -30,7 +30,8 @@
GET_FILENAME_COMPONENT( MODULE_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME )
# setup the target directories and names
SET( MODULE_TARGET_DIR ${OWModuleTargetDir}/${MODULE_NAME} )
SET( MODULE_TARGET_DIR_RELATIVE ${OW_MODULE_DIR_RELATIVE}/${MODULE_NAME} )
SET( MODULE_TARGET_DIR ${OW_MODULE_DIR}/${OW_MODULE_DIR_RELATIVE} )
SET( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${MODULE_TARGET_DIR} )
SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${MODULE_TARGET_DIR} )
SET( MODULE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} )
......@@ -77,7 +78,7 @@ SETUP_TESTS( "${TARGET_TEST_FILES}" "${MODULE_NAME}" "${_MODULE_DEPENDENCIES}" )
# -----------------------------------------------------------------------------------------------------------------------------------------------
COLLECT_SHADER_FILES( ${MODULE_SOURCE_DIR} TARGET_GLSL_FILES )
SETUP_SHADERS( "${TARGET_GLSL_FILES}" "${MODULE_TARGET_DIR}/shaders" )
SETUP_SHADERS( "${TARGET_GLSL_FILES}" "${MODULE_TARGET_DIR_RELATIVE}/shaders" )
# -----------------------------------------------------------------------------------------------------------------------------------------------
# Style Checker
......
......@@ -67,7 +67,8 @@ FUNCTION( SETUP_MODULE _MODULE_NAME _MODULE_SOURCE_DIR _MODULE_DEPENDENCIES _MOD
# setup the target directories and names
SET( MODULE_NAME ${_MODULE_NAME} )
SET( MODULE_TARGET_DIR ${OWModuleTargetDir}/${MODULE_NAME} )
SET( MODULE_TARGET_DIR_RELATIVE ${OW_MODULE_DIR_RELATIVE}/${MODULE_NAME} )
SET( MODULE_TARGET_DIR ${OW_MODULE_DIR}/${OW_MODULE_DIR_RELATIVE} )
SET( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${MODULE_TARGET_DIR} )
SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${MODULE_TARGET_DIR} )
SET( MODULE_SOURCE_DIR ${_MODULE_SOURCE_DIR} )
......@@ -100,7 +101,7 @@ FUNCTION( SETUP_MODULE _MODULE_NAME _MODULE_SOURCE_DIR _MODULE_DEPENDENCIES _MOD
# -----------------------------------------------------------------------------------------------------------------------------------------------
COLLECT_SHADER_FILES( ${MODULE_SOURCE_DIR} TARGET_GLSL_FILES )
SETUP_SHADERS( "${TARGET_GLSL_FILES}" "${MODULE_TARGET_DIR}/shaders" )
SETUP_SHADERS( "${TARGET_GLSL_FILES}" "${MODULE_TARGET_DIR_RELATIVE}/shaders" )
# -----------------------------------------------------------------------------------------------------------------------------------------------
# Style Checker
......
......@@ -144,9 +144,12 @@ FUNCTION( SETUP_TESTS _TEST_FILES _TEST_TARGET )
ENDIF( OW_COMPILE_TESTS )
ENDFUNCTION( SETUP_TESTS )
# This function sets up the build system to ensure that the specified list of shaders is available after build in the target directory.
# This function sets up the build system to ensure that the specified list of shaders is available after build in the target directory. It
# additionally setups the install targets. Since build and install structure are the same, specify only relative targets here which are used for
# both.
# _Shaders list of shaders
# _TargetDir the directory where to put the shaders
# _TargetDir the directory where to put the shaders. Relative to ${PROJECT_BINARY_DIR} and install dir. You should avoid ".." stuff. This can
# break the install targets
FUNCTION( SETUP_SHADERS _Shaders _TargetDir )
# only if we are allowed to
IF( OW_HANDLE_SHADERS )
......@@ -158,13 +161,18 @@ FUNCTION( SETUP_SHADERS _Shaders _TargetDir )
SET( ShaderOperation "create_symlink" )
ENDIF( OW_LINK_SHADERS )
# now do the operation for each shader
# now do the operation for each shader into build dir
FOREACH( fname ${_Shaders} )
# We need the plain filename (create_symlink needs it)
STRING( REGEX REPLACE "^.*/" "" StrippedFileName "${fname}" )
# let cmake do it
EXECUTE_PROCESS( COMMAND ${CMAKE_COMMAND} -E ${ShaderOperation} ${fname} "${_TargetDir}/${StrippedFileName}" )
EXECUTE_PROCESS( COMMAND ${CMAKE_COMMAND} -E ${ShaderOperation} ${fname} "${PROJECT_BINARY_DIR}/${_TargetDir}/${StrippedFileName}" )
ENDFOREACH( fname )
# now add install targets for each shader. All paths are relative to the current source dir.
FOREACH( fname ${_Shaders} )
INSTALL( FILES ${fname} DESTINATION ${_TargetDir} )
ENDFOREACH( fname )
ENDIF( OW_HANDLE_SHADERS )
ENDFUNCTION( SETUP_SHADERS )
......@@ -220,3 +228,18 @@ FUNCTION( SETUP_STYLECHECKER _TargetName _CheckFiles _Excludes )
ADD_DEPENDENCIES( stylecheck "stylecheck_${_TargetName}" )
ENDFUNCTION( SETUP_STYLECHECKER )
# This function handles local resources needed for program execution. Place your resources in "${CMAKE_CURRENT_SOURCE_DIR}/../resources/". They
# get copied to the build directory and a proper install target is provided too
FUNCTION( SETUP_RESOURCES )
# as all the resources with the correct directory structure reside in ../resources, this target is very easy to handle
SET( ResourcesPath "${CMAKE_CURRENT_SOURCE_DIR}/../resources/" )
ADD_CUSTOM_TARGET( ResourceConfiguration
ALL
COMMAND ${CMAKE_COMMAND} -E copy_directory "${ResourcesPath}" "${PROJECT_BINARY_DIR}/"
COMMENT "Copying resources to build directory"
)
# Also specify install target
INSTALL( DIRECTORY ${ResourcesPath} DESTINATION "." )
ENDFUNCTION( SETUP_RESOURCES )
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment