CMakeLists.txt 2.81 KB
Newer Older
1 2 3
FILE( GLOB COMMON_SRC "*.cpp" "*.h" )
FILE( GLOB COMMON_DATASTRUCTURES_SRC "datastructures/*.cpp" "datastructures/*.h" )
FILE( GLOB COMMON_EXCEPTIONS_SRC "exceptions/*.cpp" "exceptions/*.h" )
4
FILE( GLOB MATH_SRC "math/*.cpp" "math/*.h" "math/linearAlgebra/*.cpp" "math/linearAlgebra/*.h" )
ebaum's avatar
[ADD]  
ebaum committed
5

6
ADD_SUBDIRECTORY( datastructures )
7
ADD_SUBDIRECTORY( constraints )
8
ADD_SUBDIRECTORY( math )
9

10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
SET( LIB_NAME "${OWCommonName}" )

SET( ${LIB_NAME}_COMBINER_SRC ${COMMON_SRC} ${COMMON_DATASTRUCTURES_SRC} ${COMMON_EXCEPTIONS_SRC} ${MATH_SRC} )
SET( ${LIB_NAME}_ALL_CPP ${COMMON_SRC} ${COMMON_DATASTRUCTURES_SRC} ${COMMON_EXCEPTIONS_SRC} ${MATH_SRC}  )
FILE( GLOB_RECURSE ${LIB_NAME}_REMOVE_H "*.h"  )

LIST( REMOVE_ITEM ${LIB_NAME}_ALL_CPP ${${LIB_NAME}_REMOVE_H} )

IF( OW_BUILD_AS_ONE_BIG_FILE )
	SET( UNITY_BUILD_FILE_NAME "${LIB_NAME}UnityBuildFile.cpp" )
	GENERATE_UNITY_BUILD_FILE( ${LIB_NAME}_ALL_CPP )
	ADD_LIBRARY( ${LIB_NAME} SHARED ${UNITY_BUILD_FILE_NAME} ${${LIB_NAME}_COMBINER_SRC} )
ENDIF( OW_BUILD_AS_ONE_BIG_FILE )

IF( NOT OW_BUILD_AS_ONE_BIG_FILE )
    ADD_LIBRARY( ${LIB_NAME} SHARED ${${LIB_NAME}_COMBINER_SRC} )
ENDIF( NOT OW_BUILD_AS_ONE_BIG_FILE )

28
TARGET_LINK_LIBRARIES( ${LIB_NAME} ${Boost_LIBRARIES} ${CMAKE_DL_LIBS} ${OPENSCENEGRAPH_LIBRARIES} )
29

30
IF(MSVC_IDE)
31
    SET_TARGET_PROPERTIES( ${LIB_NAME} PROPERTIES PREFIX "../")
32 33
ENDIF(MSVC_IDE)

34 35
# 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
36
# with these defines. Unfortunately, the Visual Studio has problems handling
37
# the quotes on the command line. WSharedLib::getSystemPrefix and
38 39
# getSystemSuffix hard codes the right strings for VC.
# Maybe you have to spend another 500 bucks to have your VC support quotes.
40
IF( NOT CMAKE_GENERATOR MATCHES "Visual Studio" )
41 42
    add_definitions( '-DW_LIB_PREFIX="${CMAKE_SHARED_LIBRARY_PREFIX}"' )
    add_definitions( '-DW_LIB_SUFFIX="${CMAKE_SHARED_LIBRARY_SUFFIX}"' )
43
ENDIF()
ebaum's avatar
[ADD]  
ebaum committed
44 45

# Unit tests
46
IF( OW_COMPILE_TESTS )
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
    CXXTEST_ADD_TESTS_FROM_LIST( "${COMMON_SRC}"
        "${LIB_NAME}"
        "WSegmentationFault.cpp" # can't test seg-faults ;-)
        "WTransferable.cpp"  # its an empty class
        "WPropertyBase.cpp" # its an abstract class. Its small functionality is tested in WPropertyVariable_test.h
        "WLimits.cpp" # there are only some definitions
        )

    # Copy fixtures if existend
    IF( EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/test/fixtures )
        ADD_CUSTOM_TARGET( ${LIB_NAME}_CopyFixtures
            COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/test/fixtures ${CMAKE_BINARY_DIR}/common/fixtures/
            COMMENT "Copy fixtures of ${LIB_NAME}"
            )
        ADD_DEPENDENCIES( ${LIB_NAME} ${LIB_NAME}_CopyFixtures )
    ENDIF( EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/test/fixtures )
63
ENDIF( OW_COMPILE_TESTS )