Commit 0fe99c00 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[CHANGE] - unified test setup stuff in cmake.

parent a2960549
#---------------------------------------------------------------------------
#
# 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/>.
#
#---------------------------------------------------------------------------
# ---------------------------------------------------------------------------------------------------------------------------------------------------
#
# General CMake Setup
......@@ -196,8 +220,14 @@ ENDIF()
#
# ---------------------------------------------------------------------------------------------------------------------------------------------------
# This script contains all the needed tools to setup the build
INCLUDE( ${PROJECT_SOURCE_DIR}/../tools/CMakeModules/BuildUtils.cmake )
# libcnt needs absolute inclusion somewhere
INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/ext/libeep )
INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/ext )
# to allow non-core code to access core and ext absolutely
INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR} )
# -----------------------------------------------------------------------------------------------------------------------------------------------
......
#---------------------------------------------------------------------------
#
# 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/>.
#
#---------------------------------------------------------------------------
# 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
......@@ -9,60 +33,28 @@ IF( NOT CMAKE_GENERATOR MATCHES "Visual Studio" )
ADD_DEFINITIONS( '-DW_LIB_SUFFIX="${CMAKE_SHARED_LIBRARY_SUFFIX}"' )
ENDIF()
# ---------------------------------------------------------------------------------------------------------------------------------------------------
# Add sources as target
# ---------------------------------------------------------------------------------------------------------------------------------------------------
# Collect the compile-files for OWCore
COLLECT_COMPILE_FILES( "${CMAKE_CURRENT_SOURCE_DIR}" CORE_CPP_FILES CORE_H_FILES CORE_TEST_FILES )
# Setup the OWCore target
ADD_LIBRARY( ${OWCoreName} SHARED ${CORE_CPP_FILES} ${CORE_H_FILES} )
TARGET_LINK_LIBRARIES( ${OWCoreName} ${Boost_LIBRARIES} ${CMAKE_DL_LIBS} ${OPENGL_gl_LIBRARY} ${OPENSCENEGRAPH_LIBRARIES} ${OWExtBioSigName} ${OWExtEEPName} ${OWExtNiftiName} )
# Setup tests of this target
# Unit tests
IF( OW_COMPILE_TESTS )
TARGET_LINK_LIBRARIES( ${OWCoreName} ${OWExtBioSigName} ${OWExtEEPName} ${OWExtNiftiName}
${Boost_LIBRARIES} ${CMAKE_DL_LIBS} ${OPENGL_gl_LIBRARY} ${OPENSCENEGRAPH_LIBRARIES}
)
# Add each found test and create a target for it
FOREACH( testfile ${CORE_TEST_FILES} )
# strip path and extension
STRING( REGEX REPLACE "^.*/" "" StrippedTestFile "${testfile}" )
STRING( REGEX REPLACE "\\..*$" "" PlainTestFileName "${StrippedTestFile}" )
STRING( REGEX REPLACE "_test$" "" TestFileClass "${PlainTestFileName}" )
# ---------------------------------------------------------------------------------------------------------------------------------------------------
# Test Setup
# ---------------------------------------------------------------------------------------------------------------------------------------------------
# create some name for the test
SET( UnitTestName "unittest_${TestFileClass}" )
# create the test-target
CXXTEST_ADD_TEST( ${UnitTestName} "${UnitTestName}.cc" ${testfile} )
TARGET_LINK_LIBRARIES( ${UnitTestName} ${OWCoreName} )
ENDFOREACH( testfile )
# direct globbing of files by only knowing a part of the path is not possible -> so get all files and filter later
FILE( GLOB_RECURSE everything "${CMAKE_CURRENT_SOURCE_DIR}/*" )
SET( FixturePaths )
FOREACH( fixture ${everything} )
# is this a fixture?
STRING( REGEX MATCH "test\\/fixtures" IsFixture "${fixture}" )
IF( IsFixture ) # found a fixture.
# strip filename from path and keep only path
STRING( REGEX REPLACE "fixtures/.*$" "fixtures" FixturePath "${fixture}" )
# add it to a list
LIST( APPEND FixturePaths ${FixturePath} )
ENDIF( IsFixture )
ENDFOREACH( fixture )
# Setup tests of this target
SETUP_TESTS( "${CORE_TEST_FILES}" "${OWCoreName}" "" )
# the list may contain duplicates
LIST( REMOVE_DUPLICATES FixturePaths )
# 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}" )
# ---------------------------------------------------------------------------------------------------------------------------------------------------
# Copy Resources
# ---------------------------------------------------------------------------------------------------------------------------------------------------
# finally, create the copy target
ADD_CUSTOM_TARGET( ${OWCoreName}_CopyFixtures_${FixtureDirEscaped}
COMMAND ${CMAKE_COMMAND} -E copy_directory "${FixtureDir}" ${CMAKE_BINARY_DIR}/core/fixtures/
COMMENT "Copy fixtures of ${OWCoreName} from ${FixtureDir}."
)
ADD_DEPENDENCIES( ${OWCoreName} ${OWCoreName}_CopyFixtures_${FixtureDirEscaped} )
ENDFOREACH( FixtureDir )
ENDIF( OW_COMPILE_TESTS )
......@@ -92,7 +92,7 @@ public:
void testReadFileIntoString( void )
{
std::string expected = "Hello Pansen!\r\n";
std::string actual = readFileIntoString( boost::filesystem::path( "fixtures/hello.world" ) );
std::string actual = readFileIntoString( boost::filesystem::path( W_FIXTURE_PATH + "hello.world" ) );
TS_ASSERT_EQUALS( expected, actual );
}
......
......@@ -43,7 +43,7 @@ public:
*/
void testLoading( void )
{
std::string fileName = "../fixtures/eeg_testData.asc";
std::string fileName = W_FIXTURE_PATH + "eeg_testData.asc";
std::cout << std::endl << "Test loading of " << fileName << "." << std::endl;
WReaderEEGASCII eegASCIIReader( fileName );
......
......@@ -70,12 +70,12 @@ public:
*/
void testInstantiation( void )
{
TS_ASSERT_THROWS_NOTHING( WReaderNIfTI( "../fixtures/scalar_signed_short.nii.gz" ) );
TS_ASSERT_THROWS_NOTHING( WReaderNIfTI( "../fixtures/scalar_unsigned_char.nii.gz" ) );
TS_ASSERT_THROWS_NOTHING( WReaderNIfTI( "../fixtures/scalar_float.nii.gz" ) );
TS_ASSERT_THROWS_NOTHING( WReaderNIfTI( "../fixtures/vector_float.nii.gz" ) );
TS_ASSERT_THROWS_NOTHING( WReaderNIfTI( "../fixtures/symmetric_2nd_order_tensor_float.nii.gz" ) );
TS_ASSERT_THROWS_NOTHING( WReaderNIfTI( "../fixtures/vector_unsigned_char.nii.gz" ) );
TS_ASSERT_THROWS_NOTHING( WReaderNIfTI( W_FIXTURE_PATH + "scalar_signed_short.nii.gz" ) );
TS_ASSERT_THROWS_NOTHING( WReaderNIfTI( W_FIXTURE_PATH + "scalar_unsigned_char.nii.gz" ) );
TS_ASSERT_THROWS_NOTHING( WReaderNIfTI( W_FIXTURE_PATH + "scalar_float.nii.gz" ) );
TS_ASSERT_THROWS_NOTHING( WReaderNIfTI( W_FIXTURE_PATH + "vector_float.nii.gz" ) );
TS_ASSERT_THROWS_NOTHING( WReaderNIfTI( W_FIXTURE_PATH + "symmetric_2nd_order_tensor_float.nii.gz" ) );
TS_ASSERT_THROWS_NOTHING( WReaderNIfTI( W_FIXTURE_PATH + "vector_unsigned_char.nii.gz" ) );
}
/**
......@@ -83,7 +83,7 @@ public:
*/
void testLoading1( void )
{
WReaderNIfTI reader1( "../fixtures/scalar_signed_short.nii.gz" );
WReaderNIfTI reader1( W_FIXTURE_PATH + "scalar_signed_short.nii.gz" );
TS_ASSERT( reader1.load() );
}
......@@ -92,7 +92,7 @@ public:
*/
void testLoading2( void )
{
WReaderNIfTI reader2( "../fixtures/scalar_unsigned_char.nii.gz" );
WReaderNIfTI reader2( W_FIXTURE_PATH + "scalar_unsigned_char.nii.gz" );
TS_ASSERT( reader2.load() );
}
......@@ -101,7 +101,7 @@ public:
*/
void testLoading3( void )
{
WReaderNIfTI reader3( "../fixtures/scalar_float.nii.gz" );
WReaderNIfTI reader3( W_FIXTURE_PATH + "scalar_float.nii.gz" );
TS_ASSERT( reader3.load() );
}
......@@ -110,7 +110,7 @@ public:
*/
void testLoading4( void )
{
WReaderNIfTI reader4( "../fixtures/vector_float.nii.gz" );
WReaderNIfTI reader4( W_FIXTURE_PATH + "vector_float.nii.gz" );
TS_ASSERT( reader4.load() );
}
......@@ -119,7 +119,7 @@ public:
*/
void testLoading5( void )
{
WReaderNIfTI reader5( "../fixtures/symmetric_2nd_order_tensor_float.nii.gz" );
WReaderNIfTI reader5( W_FIXTURE_PATH + "symmetric_2nd_order_tensor_float.nii.gz" );
TS_ASSERT( reader5.load() );
}
......@@ -128,7 +128,7 @@ public:
*/
void testLoading6( void )
{
WReaderNIfTI reader6( "../fixtures/vector_unsigned_char.nii.gz" );
WReaderNIfTI reader6( W_FIXTURE_PATH + "vector_unsigned_char.nii.gz" );
TS_ASSERT( reader6.load() );
}
......@@ -156,7 +156,7 @@ public:
dummy.m[3][3] = 1.17;
// need this for calling the function
WReaderNIfTI reader1( "../fixtures/scalar_signed_short.nii.gz" );
WReaderNIfTI reader1( W_FIXTURE_PATH + "scalar_signed_short.nii.gz" );
WMatrix< double > result = reader1.convertMatrix( dummy );
......@@ -188,7 +188,7 @@ public:
void testCopyArray( void )
{
// need this for calling the function
WReaderNIfTI reader1( "../fixtures/scalar_signed_short.nii.gz" );
WReaderNIfTI reader1( W_FIXTURE_PATH + "scalar_signed_short.nii.gz" );
const size_t nbVoxels = 10;
const size_t vDim = 3;
......
#---------------------------------------------------------------------------
#
# 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/>.
#
#---------------------------------------------------------------------------
# Unlike Utils.cmake, this file contains only build related utilities.
# Recursively searches compile files (headers, sources).
# _DirString: where to search
# _CPPFiles contains the cpp files afterwards
# _HFiles contains the h files afterwards, without tests
# _TestFiles contains only the test headers
FUNCTION( COLLECT_COMPILE_FILES _DirString _CPPFiles _HFiles _TestFiles )
# recursively get all files
FILE( GLOB_RECURSE CPP_FILES ${_DirString}/*.cpp )
FILE( GLOB_RECURSE H_FILES ${_DirString}/*.h )
FILE( GLOB_RECURSE TEST_FILES ${_DirString}/*_test.h )
# Unfortunately, this will contain the tests -> remove them explicitly
FOREACH( file ${TEST_FILES} )
LIST( REMOVE_ITEM H_FILES ${file} )
ENDFOREACH( file )
SET( ${_CPPFiles} "${CPP_FILES}" PARENT_SCOPE )
SET( ${_HFiles} "${H_FILES}" PARENT_SCOPE )
SET( ${_TestFiles} "${TEST_FILES}" PARENT_SCOPE )
ENDFUNCTION( COLLECT_COMPILE_FILES )
# Add tests and copy their fixtures by specifiying the test headers. This is completely automatic and is done recusrively (fixtures). The test
# filenames need to be absolute. The fixtures are searched in CMAKE_CURRENT_SOURCE_DIR.
# _TEST_FILES the list of test header files.
# _TEST_TARGET for which target are the tests? This is added as link library for each test too.
# Third, unnamed parameter: additional dependencies as list
FUNCTION( SETUP_TESTS _TEST_FILES _TEST_TARGET )
# Only do something if needed
IF( OW_COMPILE_TESTS )
# the optional parameter is an additional dependencies list
SET( _DEPENDENCIES ${ARGV2} )
# target directory for fixtures
SET( FixtureTargetDirectory "${CMAKE_BINARY_DIR}/core/fixtures/" )
# -------------------------------------------------------------------------------------------------------------------------------------------
# Setup CXX test
# -------------------------------------------------------------------------------------------------------------------------------------------
# Add each found test and create a target for it
FOREACH( testfile ${_TEST_FILES} )
# strip path and extension
STRING( REGEX REPLACE "^.*/" "" StrippedTestFile "${testfile}" )
STRING( REGEX REPLACE "\\..*$" "" PlainTestFileName "${StrippedTestFile}" )
STRING( REGEX REPLACE "_test$" "" TestFileClass "${PlainTestFileName}" )
# create some name for the test
SET( UnitTestName "unittest_${TestFileClass}" )
# create the test-target
CXXTEST_ADD_TEST( ${UnitTestName} "${UnitTestName}.cc" ${testfile} )
TARGET_LINK_LIBRARIES( ${UnitTestName} ${_TEST_TARGET} ${_DEPENDENCIES} )
# unfortunately, the tests search their fixtures relative to their working directory. So we add a preprocessor define containing the
# path to the fixtures. This is quite ugly but I do not know how to ensure that the working directory of tests can be modified.
SET_SOURCE_FILES_PROPERTIES( "${UnitTestName}.cc" PROPERTIES COMPILE_DEFINITIONS "W_FIXTURE_PATH=std::string( \"${FixtureTargetDirectory}\" )" )
ENDFOREACH( testfile )
# -------------------------------------------------------------------------------------------------------------------------------------------
# Search fixtures
# -------------------------------------------------------------------------------------------------------------------------------------------
# direct globbing of files by only knowing a part of the path is not possible -> so get all files and filter later
FILE( GLOB_RECURSE everything "${CMAKE_CURRENT_SOURCE_DIR}/*" )
SET( FixturePaths )
FOREACH( fixture ${everything} )
# is this a fixture?
STRING( REGEX MATCH "test\\/fixtures" IsFixture "${fixture}" )
IF( IsFixture ) # found a fixture.
# strip filename from path and keep only path
STRING( REGEX REPLACE "fixtures/.*$" "fixtures" FixturePath "${fixture}" )
# add it to a list
LIST( APPEND FixturePaths ${FixturePath} )
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 )
ENDIF( OW_COMPILE_TESTS )
ENDFUNCTION( SETUP_TESTS )
#
# Usage: GENERATE_UNITY_BUILD_FILE( projectFilesVariableName )
#
# Takes the list of files in the project and makes an ${UNITY_BUILD_FILE_NAME} files that
# #includes all of the source files. Adds ${UNITY_BUILD_FILE_NAME} to the list of source files.
#
# This is a compilation speedup technique suggested on various web sites such as:
# http://buffered.io/2007/12/10/the-magic-of-unity-builds/
# http://stackoverflow.com/questions/543697/include-all-cpp-files-into-a-single-compilation-unit
#
#You can use it like this:
#SET( PROJECT_SOURCES file1.cpp file1.h file2.cpp, file2.h )
#SET( UNITY_BUILD_FILE_NAME "_UnityBuildFile.cpp" )
#GENERATE_UNITY_BUILD_FILE( PROJECT_SOURCES )
macro( GENERATE_UNITY_BUILD_FILE projectFilesVariableName )
set( PROJECT_SINGLE_FILE ${CMAKE_CURRENT_BINARY_DIR}/${UNITY_BUILD_FILE_NAME} )
# Generate list of project source files and set them to be excluded from the build
# FILE_LIST_BODIES( PROJECT_SOURCES ${${projectFilesVariableName}} )
FILE( GLOB PROJECT_SOURCES ${${projectFilesVariableName}} )
foreach( source_file ${PROJECT_SOURCES} )
# Dont add qrc_* generated files to ${UNITY_BUILD_FILE_NAME} if more than one they clash with each other!
if( NOT source_file MATCHES ".*qrc_.*" )
# Mark source files as "header" so it will be excluded from the build
SET_PROPERTY( SOURCE ${source_file} PROPERTY HEADER_FILE_ONLY true )
endif( NOT source_file MATCHES ".*qrc_.*" )
endforeach( source_file ${ARG_FILES} )
# Add this derived file to the project
# LIST( APPEND ${projectFilesVariableName} ${PROJECT_SINGLE_FILE} )
# Check to see if .parameters file matches ${PROJECT_SOURCES} if so dont need to regenerate ${UNITY_BUILD_FILE_NAME}
# SET( PROJECT_SINGLE_FILE_PARAMETERS ${PROJECT_SINGLE_FILE}.parameters )
# if( EXISTS ${PROJECT_SINGLE_FILE_PARAMETERS} )
# FILE( READ ${PROJECT_SINGLE_FILE_PARAMETERS} PROJECT_PARAMETERS )
# endif( EXISTS ${PROJECT_SINGLE_FILE_PARAMETERS} )
# if ( PROJECT_PARAMETERS STREQUAL PROJECT_SOURCES )
# Do nothing since current parameters match parameters used to generate ${UNITY_BUILD_FILE_NAME}
# else ( PROJECT_PARAMETERS STREQUAL PROJECT_SOURCES )
# Store the list of PROJECT_SOURCES in a .parameters file to see if need to regenerate ${UNITY_BUILD_FILE_NAME} or not
# FILE( WRITE ${PROJECT_SINGLE_FILE_PARAMETERS} "${PROJECT_SOURCES}" )
# Now generate the single project source file
# foreach( source_file ${PROJECT_SOURCES} )
# Dont add qrc_* generated files to ${UNITY_BUILD_FILE_NAME} if more than one they clash with each other!
# if( NOT source_file MATCHES ".*qrc_.*" )
# Write the inclujde line to the newly-generated project single source file
# FILE( APPEND ${PROJECT_SINGLE_FILE} "#include \"" ${source_file} "\"\n" )
# endif( NOT source_file MATCHES ".*qrc_.*" )
# endforeach( source_file ${ARG_FILES} )
# endif ( PROJECT_PARAMETERS STREQUAL PROJECT_SOURCES )
SET( PROJECT_TMP_FILE ${PROJECT_SINGLE_FILE}.tmp )
FILE( WRITE ${PROJECT_TMP_FILE} "" )
foreach( source_file ${PROJECT_SOURCES} )
# Write the inclujde line to the newly-generated project single source file
if( NOT source_file MATCHES ".*qrc_.*" )
# Write the inclujde line to the newly-generated project single source file
FILE( APPEND ${PROJECT_TMP_FILE} "#include \"" ${source_file} "\"\n" )
endif( NOT source_file MATCHES ".*qrc_.*" )
endforeach( source_file ${ARG_FILES} )
# check if the file changed or exists at all, dont copy if its the same
EXECUTE_PROCESS(
COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/../tools/copyIfNes.py ${UNITY_BUILD_FILE_NAME}.tmp ${UNITY_BUILD_FILE_NAME}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
endmacro( GENERATE_UNITY_BUILD_FILE projectFilesVariableName )
macro( GENERATE_PCH_LIST_FILE projectFilesVariableName )
set( PROJECT_SINGLE_FILE ${CMAKE_CURRENT_SOURCE_DIR}/Filelist.txt )
FILE( GLOB PROJECT_SOURCES ${${projectFilesVariableName}} )
# FILE( WRITE ${PROJECT_SINGLE_FILE} "${PROJECT_SOURCES}" )
# Now generate the single file list
FILE( WRITE ${PROJECT_SINGLE_FILE} "" )
foreach( source_file ${PROJECT_SOURCES} )
# Write the inclujde line to the newly-generated project single source file
if( NOT source_file MATCHES ".*moc_.*" )
FILE( APPEND ${PROJECT_SINGLE_FILE} "" ${source_file} "\n" )
endif( NOT source_file MATCHES ".*moc_.*" )
endforeach( source_file ${ARG_FILES} )
endmacro( GENERATE_PCH_LIST_FILE projectFilesVariableName )
macro( CLEAN_PCH_IF_NECESSARY LIB_NAME LIB_SOURCE_FILES )
IF( ( ( NOT OW_BUILD_WITH_PCH ) OR OW_BUILD_AS_ONE_BIG_FILE ) AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LIB_NAME}_PCH.cpp )
GENERATE_PCH_LIST_FILE( ${LIB_SOURCE_FILES} )
EXECUTE_PROCESS(
COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/../tools/createPCH.py ${LIB_NAME} Filelist.txt 0
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
FILE( REMOVE ${CMAKE_CURRENT_SOURCE_DIR}/Filelist.txt )
#message("${${LIB_NAME}_ALL_CPP}")
#message("${LIB_NAME}_ALL_CPP")
#message("${${${LIB_NAME}_REMOVE_PCH}}")
#message("${${LIB_NAME}_REMOVE_PCH}")
#message("${LIB_NAME}_REMOVE_PCH")
LIST( REMOVE_ITEM ${LIB_NAME}_ALL_CPP ${${LIB_NAME}_REMOVE_PCH} )
#message("${LIB_NAME}_ALL_CPP")
#message("${${LIB_NAME}_ALL_CPP}")
LIST( REMOVE_ITEM ${LIB_NAME}_COMBINER_SRC ${${LIB_NAME}_REMOVE_PCH} )
ENDIF( ( ( NOT OW_BUILD_WITH_PCH ) OR OW_BUILD_AS_ONE_BIG_FILE) AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LIB_NAME}_PCH.cpp )
endmacro( CLEAN_PCH_IF_NECESSARY LIB_NAME LIB_SOURCE_FILES )
macro( CREATE_PCH LIB_NAME LIB_SOURCE_FILES LIB_SOURCEFILES_WITHOUT_HEADER SOURCES_WITHOUT_MOC )
GENERATE_PCH_LIST_FILE( ${LIB_SOURCE_FILES} )
EXECUTE_PROCESS(
COMMAND ${CMAKE_COMMAND} -E environment
COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/../tools/createPCH.py ${LIB_NAME} Filelist.txt 1
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
ADD_LIBRARY( ${LIB_NAME} SHARED ${LIB_NAME}_PCH.cpp ${${LIB_SOURCE_FILES}} )
IF(MSVC)
#make sure to not do that to moc files
SET_SOURCE_FILES_PROPERTIES( ${${SOURCES_WITHOUT_MOC}} PROPERTIES COMPILE_FLAGS "/Yu${LIB_NAME}_PCH.h /Fp${LIB_NAME}_PCH.pch" )
SET_SOURCE_FILES_PROPERTIES( ${LIB_NAME}_PCH.cpp PROPERTIES COMPILE_FLAGS "/Yc${LIB_NAME}_PCH.h /Fp${LIB_NAME}_PCH.pch" )
ENDIF(MSVC)
# IF(CMAKE_COMPILER_IS_GNUCXX)
# ADD_PRECOMPILED_HEADER( ${LIB_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/${LIB_NAME}_PCH.h )
# ENDIF(CMAKE_COMPILER_IS_GNUCXX)
FILE( REMOVE ${CMAKE_CURRENT_SOURCE_DIR}/Filelist.txt )
endmacro( CREATE_PCH LIB_NAME LIB_SOURCE_FILES LIB_SOURCEFILES_WITHOUT_HEADER SOURCES_WITHOUT_MOC )
macro( CREATE_PCH_NOT_SHARED LIB_NAME LIB_SOURCE_FILES LIB_SOURCEFILES_WITHOUT_HEADER SOURCES_WITHOUT_MOC )
GENERATE_PCH_LIST_FILE( ${LIB_SOURCE_FILES} )
EXECUTE_PROCESS(
COMMAND ${CMAKE_COMMAND} -E environment
COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/../tools/createPCH.py ${LIB_NAME} Filelist.txt 1
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
ADD_LIBRARY( ${LIB_NAME} ${LIB_NAME}_PCH.cpp ${${LIB_SOURCE_FILES}} )
IF(MSVC)
#make sure to not do that to moc files
SET_SOURCE_FILES_PROPERTIES( ${${SOURCES_WITHOUT_MOC}} PROPERTIES COMPILE_FLAGS "/Yu${LIB_NAME}_PCH.h /Fp${LIB_NAME}_PCH.pch" )
SET_SOURCE_FILES_PROPERTIES( ${LIB_NAME}_PCH.cpp PROPERTIES COMPILE_FLAGS "/Yc${LIB_NAME}_PCH.h /Fp${LIB_NAME}_PCH.pch" )
ENDIF(MSVC)
# IF(CMAKE_COMPILER_IS_GNUCXX)
# ADD_PRECOMPILED_HEADER( ${LIB_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/${LIB_NAME}_PCH.h )
# ENDIF(CMAKE_COMPILER_IS_GNUCXX)
FILE( REMOVE ${CMAKE_CURRENT_SOURCE_DIR}/Filelist.txt )
endmacro( CREATE_PCH_NOT_SHARED LIB_NAME LIB_SOURCE_FILES LIB_SOURCEFILES_WITHOUT_HEADER SOURCES_WITHOUT_MOC )
#---------------------------------------------------------------------------
#
# 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/>.
#
#---------------------------------------------------------------------------
FUNCTION( SPLIT_VERSION_STRING _VersionString _Major _Minor _Patch )
STRING( STRIP _VersionString ${_VersionString} )
STRING( REGEX MATCH "^[0-9]+" _MajorProxy "${_VersionString}" )
......@@ -9,7 +33,10 @@ FUNCTION( SPLIT_VERSION_STRING _VersionString _Major _Minor _Patch )
SET( ${_Patch} "${_PatchProxy}" PARENT_SCOPE )
ENDFUNCTION( SPLIT_VERSION_STRING )
# Ensures a minimal version for a given package name.
# _PackageName The package name. Needed for the message
# _ActualVersion The version that was found
# _MinimumVersion The minimum version
FUNCTION( ASSERT_GE_VERSION _PackageName _ActualVersion _MinimumVersion )
SPLIT_VERSION_STRING( ${_ActualVersion} _ActualMajor _ActualMinor _ActualPatch )
SPLIT_VERSION_STRING( ${_MinimumVersion} _MinimumMajor _MinimumMinor _MinimumPatch )
......@@ -29,24 +56,3 @@ FUNCTION( ASSERT_GE_VERSION _PackageName _ActualVersion _MinimumVersion )
ENDIF()
ENDFUNCTION( ASSERT_GE_VERSION )
# Recursively searches compile files (headers, sources).
# _DirString: where to search
# _CPPFiles contains the cpp files afterwards
# _HFiles contains the h files afterwards, without tests
# _TestFiles contains only the test headers
FUNCTION( COLLECT_COMPILE_FILES _DirString _CPPFiles _HFiles _TestFiles )
# recursively get all files
FILE( GLOB_RECURSE CPP_FILES ${_DirString}/*.cpp )
FILE( GLOB_RECURSE H_FILES ${_DirString}/*.h )
FILE( GLOB_RECURSE TEST_FILES ${_DirString}/*_test.h )
# Unfortunately, this will contain the tests -> remove them explicitly
FOREACH( file ${TEST_FILES} )
LIST( REMOVE_ITEM H_FILES ${file} )
ENDFOREACH( file )
SET( ${_CPPFiles} "${CPP_FILES}" PARENT_SCOPE )
SET( ${_HFiles} "${H_FILES}" PARENT_SCOPE )
SET( ${_TestFiles} "${TEST_FILES}" PARENT_SCOPE )
ENDFUNCTION( COLLECT_COMPILE_FILES )
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