speed-dreams-code/cmake/macros.cmake
pouillot 003f0bc2cc Re #224 Secured ROBOT, ROBOT_MODULE and ROBOT_DATA macros (end)
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@3052 30fe4595-0a0c-4342-8851-515496e4dcbd

Former-commit-id: a5ab5729076837ebec14bda439a47d5b96a685c2
Former-commit-id: 597ad0d597b6bf58b0bc9a804c8568a691b79723
2010-10-24 13:42:25 +00:00

1220 lines
50 KiB
CMake

IF(NOT DEFINED IN_SOURCETREE)
SET(IN_SOURCETREE TRUE)
ENDIF(NOT DEFINED IN_SOURCETREE)
IF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
IF(WIN32)
SET(CMAKE_INSTALL_PREFIX "C:/Program files/speed-dreams-dev" CACHE PATH "Prefix prepended to install directories" FORCE)
ELSE()
SET(CMAKE_INSTALL_PREFIX "/usr/local/dev" CACHE PATH "Prefix prepended to install directories" FORCE)
ENDIF()
ENDIF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
IF(NOT SOURCE_DIR AND IN_SOURCETREE)
FIND_PATH(SOURCE_CMAKE_PATH cmake/macros.cmake PATHS . .. ../.. ../../.. ../../../.. ../../../../.. ../../../../../.. ../../../../../../.. ../../../../../../../.. ${CMAKE_SOURCE_DIR} NO_DEFAULT_PATH)
FIND_PATH(SOURCE_CMAKE_PATH cmake/macros.cmake PATHS . .. ../.. ../../.. ../../../.. ../../../../.. ../../../../../.. ../../../../../../.. ../../../../../../../.. ${CMAKE_SOURCE_DIR})
GET_FILENAME_COMPONENT(SOURCE_DIR ${SOURCE_CMAKE_PATH} ABSOLUTE CACHE)
SET(SOURCE_CMAKE_PATH "")
ENDIF(NOT SOURCE_DIR AND IN_SOURCETREE)
GET_FILENAME_COMPONENT(CURRENT_LIST_FILE_PATH ${CMAKE_CURRENT_LIST_FILE} PATH)
INCLUDE(${CURRENT_LIST_FILE_PATH}/split_argn.cmake)
IF(IN_SOURCETREE)
FIND_PATH(CONFIGH_INCLUDE_DIR config.h PATHS ${SOURCE_DIR} ${CMAKE_BINARY_DIR} NO_DEFAULT_PATH)
FIND_PATH(CONFIGH_INCLUDE_DIR config.h PATHS ${SOURCE_DIR} ${CMAKE_BINARY_DIR})
IF(CONFIGH_INCLUDE_DIR)
SET(HAVE_CONFIG_H TRUE)
ELSE(CONFIGH_INCLUDE_DIR)
SET(HAVE_CONFIG_H FALSE)
ENDIF(CONFIGH_INCLUDE_DIR)
ELSE(IN_SOURCETREE)
SET(HAVE_CONFIG_H FALSE)
ENDIF(IN_SOURCETREE)
IF(WIN32)
SET(SD_LOCALDIR "~/speed-dreams-dev.settings" CACHE DOC "Where the user settings files should go")
ELSE(WIN32) #UNIX
SET(SD_LOCALDIR "~/.speed-dreams-dev" CACHE DOC "Where the user settings files should go")
ENDIF(WIN32)
IF(IN_SOURCETREE)
IF(CMAKE_SIZEOF_VOID_P MATCHES 4)
SET(_DEFLIBDIR "lib")
ELSE()
SET(_DEFLIBDIR "lib64")
ENDIF()
IF(WIN32)
SET(SD_BINDIR bin CACHE PATH "Place where the executables should go")
SET(SD_DATADIR data CACHE PATH "Place where all the static data files should go")
SET(SD_LIBDIR ${_DEFLIBDIR} CACHE PATH "Place where the libraries should go")
SET(SD_INCLUDEDIR include CACHE PATH "Place where the include files should go")
ELSE(WIN32) #UNIX
SET(SD_BINDIR games CACHE PATH "Place where the executables should go")
SET(SD_DATADIR share/games/speed-dreams CACHE PATH "Place where all the static data files should go")
SET(SD_LIBDIR ${_DEFLIBDIR}/games/speed-dreams CACHE PATH "Place where the libraries should go")
SET(SD_INCLUDEDIR include/speed-dreams CACHE PATH "Place where the include files should go")
ENDIF(WIN32)
ELSE(IN_SOURCETREE)
SET(SD_DATADIR ${SD_DATADIR_ABS})
SET(SD_LIBDIR ${SD_LIBDIR_ABS})
SET(SD_BINDIR ${SD_BINDIR_ABS})
SET(SD_INCLUDEDIR ${SD_INCLUDEDIR_ABS})
ENDIF(IN_SOURCETREE)
IF(IS_ABSOLUTE ${SD_DATADIR})
GET_FILENAME_COMPONENT(SD_DATADIR_ABS ${SD_DATADIR} ABSOLUTE)
ELSE(IS_ABSOLUTE ${SD_DATADIR})
GET_FILENAME_COMPONENT(SD_DATADIR_ABS ${CMAKE_INSTALL_PREFIX}/${SD_DATADIR} ABSOLUTE)
ENDIF(IS_ABSOLUTE ${SD_DATADIR})
IF(IS_ABSOLUTE ${SD_LIBDIR})
GET_FILENAME_COMPONENT(SD_LIBDIR_ABS ${SD_LIBDIR} ABSOLUTE)
ELSE(IS_ABSOLUTE ${SD_LIBDIR})
GET_FILENAME_COMPONENT(SD_LIBDIR_ABS ${CMAKE_INSTALL_PREFIX}/${SD_LIBDIR} ABSOLUTE)
ENDIF(IS_ABSOLUTE ${SD_LIBDIR})
IF(IS_ABSOLUTE ${SD_BINDIR})
GET_FILENAME_COMPONENT(SD_BINDIR_ABS ${SD_BINDIR} ABSOLUTE)
ELSE(IS_ABSOLUTE ${SD_BINDIR})
GET_FILENAME_COMPONENT(SD_BINDIR_ABS ${CMAKE_INSTALL_PREFIX}/${SD_BINDIR} ABSOLUTE)
ENDIF(IS_ABSOLUTE ${SD_BINDIR})
IF(IS_ABSOLUTE ${SD_INCLUDEDIR})
GET_FILENAME_COMPONENT(SD_INCLUDEDIR_ABS ${SD_INCLUDEDIR} ABSOLUTE)
ELSE(IS_ABSOLUTE ${SD_INCLUDEDIR})
GET_FILENAME_COMPONENT(SD_INCLUDEDIR_ABS ${CMAKE_INSTALL_PREFIX}/${SD_INCLUDEDIR} ABSOLUTE)
ENDIF(IS_ABSOLUTE ${SD_INCLUDEDIR})
STRING(REGEX REPLACE "^(.*[^/])/*$" "\\1" SD_LOCALDIR_TMP ${SD_LOCALDIR})
SET(SD_LOCALDIR ${SD_LOCALDIR_TMP})
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CURRENT_LIST_FILE_PATH})
SET(CMAKE_INSTALL_RPATH "${SD_LIBDIR_ABS}/lib")
# Robot .def file generation for Windows
# ROBOTNAME : Name of the robot
# DEF_FILE : Target .def file path-name
# Other args : Robot DLL Interface description, as a list of names of exported symbols,
# but with keywords shortcuts :
# - if empty, assumed keyword "LEGACY_MIN"
# - if "LEGACY_MIN", means the smallest legacy scheme interface (TORCS style)
# with only "${NAME}" exported
# - if "LEGACY", means the complete legacy scheme interface,
# with "${NAME}" and "${NAME}Shut" exported
# - if "WELCOME", means the complete new scheme interface (Speed Dreams style),
# with "moduleWelcome", "moduleInitialize" and "moduleTerminate"
# exported
# - may be a list of above keywords for multi-scheme interface
# - may also be the raw list of symbols to export
MACRO(GENERATE_ROBOT_DEF_FILE ROBOTNAME DEF_FILE)
# Build the real list of exported symbols from the given one (that may include shortcuts)
#MESSAGE(STATUS "Generating ${DEF_FILE} for ${ROBOTNAME} robot")
SET(SYMBOLS) # Initialize the list
FOREACH(KEYSYM ${ARGN})
IF(KEYSYM STREQUAL "LEGACY_MIN")
LIST(APPEND SYMBOLS ${ROBOTNAME})
ELSEIF(KEYSYM STREQUAL "LEGACY")
LIST(APPEND SYMBOLS ${ROBOTNAME})
LIST(APPEND SYMBOLS "${ROBOTNAME}Shut")
ELSEIF(KEYSYM STREQUAL "WELCOME")
LIST(APPEND SYMBOLS moduleWelcome moduleInitialize moduleTerminate)
ELSE(KEYSYM STREQUAL "LEGACY_MIN")
LIST(APPEND SYMBOLS ${KEYSYM})
ENDIF(KEYSYM STREQUAL "LEGACY_MIN")
ENDFOREACH(KEYSYM ${ARGN})
# Clean duplicates
LIST(REMOVE_DUPLICATES SYMBOLS)
#MESSAGE(STATUS "Symbols: ${SYMBOLS}")
# Build an acceptable string for the .def file from this symbol list
SET(ROBOTSYMBOLS "")
FOREACH(SYMBOL ${SYMBOLS})
SET(ROBOTSYMBOLS "${ROBOTSYMBOLS}\n\t${SYMBOL}")
ENDFOREACH(SYMBOL ${SYMBOLS})
# Generate the .def file
IF(IN_SOURCETREE)
CONFIGURE_FILE(${SOURCE_DIR}/cmake/robot_def.cmake ${DEF_FILE})
ELSE(IN_SOURCETREE)
CONFIGURE_FILE(${SD_DATADIR_ABS}/cmake/robot_def.cmake ${DEF_FILE})
ENDIF(IN_SOURCETREE)
ENDMACRO(GENERATE_ROBOT_DEF_FILE ROBOTNAME DEF_FILE)
# Robot project definition (module build and install, without associated data)
# Args:
# NAME : Name of the robot
# INTERFACE : Robot Windows DLL Interface description (tells about exported symbols)
# See GENERATE_ROBOT_DEF_FILE macro.
# If not specified, defaults to "LEGACY_MIN" ; not used if MODULE used
# SOURCES : List of files to use as build sources if any ; not needed if MODULE used
# CLONENAMES : The names of the clones to generate
MACRO(ROBOT_MODULE)
SET(RBM_SYNTAX "NAME,1,1,RBM_HAS_NAME,RBM_NAME")
SET(RBM_SYNTAX ${RBM_SYNTAX} "INTERFACE,0,-1,RBM_HAS_INTERFACE,RBM_INTERFACE")
SET(RBM_SYNTAX ${RBM_SYNTAX} "SOURCES,0,-1,RBM_HAS_SOURCES,RBM_SOURCES")
SET(RBM_SYNTAX ${RBM_SYNTAX} "CLONENAMES,0,-1,RBM_HAS_CLONENAMES,RBM_CLONENAMES")
SPLIT_ARGN(${RBM_SYNTAX} ARGUMENTS ${ARGN})
IF(NOT RBM_HAS_NAME OR NOT RBM_NAME)
MESSAGE(FATAL_ERROR "Cannot build a robot module with no specified name")
ENDIF()
IF(NOT RBM_HAS_SOURCES OR NOT RBM_SOURCES)
MESSAGE(FATAL_ERROR "Cannot build a robot module without sources / module to copy")
ENDIF()
PROJECT("robot_${RBM_NAME}")
ADD_INTERFACE_INCLUDEDIR()
ADD_OSSPEC_INCLUDEDIR()
ADD_SDLIB_INCLUDEDIR(learning math portability robottools tgf)
ADD_PLIB_INCLUDEDIR()
# Generate / add .def file for Windows
IF(WIN32)
IF(NOT RBM_HAS_INTERFACE OR NOT RBM_INTERFACE)
SET(RBM_INTERFACE "LEGACY_MIN")
ENDIF()
SET(ROBOT_DEF_FILE ${CMAKE_CURRENT_BINARY_DIR}/${RBM_NAME}_gen.def)
GENERATE_ROBOT_DEF_FILE(${RBM_NAME} ${ROBOT_DEF_FILE} ${RBM_INTERFACE})
SET(RBM_SOURCES ${RBM_SOURCES} ${ROBOT_DEF_FILE})
ENDIF(WIN32)
# Disable developer warning
if (COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
endif(COMMAND cmake_policy)
IF(WIN32)
# Ignore some run-time libs to avoid link time warnings and sometimes even crashes.
SET(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:msvcrt.lib")
ENDIF(WIN32)
ADD_LIBRARY(${RBM_NAME} SHARED ${RBM_SOURCES})
IF(UNIX)
SET_TARGET_PROPERTIES(${RBM_NAME} PROPERTIES PREFIX "")
ENDIF(UNIX)
ADD_PLIB_LIBRARY(${RBM_NAME} sg ssg)
ADD_SDLIB_LIBRARY(${RBM_NAME} robottools)
SD_INSTALL_FILES(LIB drivers/${RBM_NAME} TARGETS ${RBM_NAME})
IF(RBM_HAS_CLONENAMES AND RBM_CLONENAMES)
GET_TARGET_PROPERTY(MODNAME ${RBM_NAME} LOCATION)
SET(MODPREFIX "")
SET(MODSUFFIX ${CMAKE_SHARED_LIBRARY_SUFFIX})
FOREACH(CLONENAME ${RBM_CLONENAMES})
SET(CLONE_MODNAME ${MODPREFIX}${CLONENAME}${MODSUFFIX})
ADD_CUSTOM_COMMAND(TARGET ${RBM_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${MODNAME} ${CLONE_MODNAME})
SD_INSTALL_FILES(LIB drivers/${CLONENAME} FILES ${CLONE_MODNAME})
ENDFOREACH(CLONENAME ${RBM_CLONENAMES})
ENDIF()
ENDMACRO(ROBOT_MODULE)
# Robot data installation
# Args:
# NAME : Name of the robot (may be a clone)
# PREFIX : Dir. prefix for source files/subdirs to install in the robot's data dir
# FILES : Extra (non default) files to install in the robot's data dir
# SUBDIRS : Data subdirectories to install in the robot's data dir
MACRO(ROBOT_DATA)
SET(RBD_SYNTAX "NAME,1,1,RBD_HAS_NAME,RBD_NAME")
SET(RBD_SYNTAX ${RBD_SYNTAX} "PREFIX,0,-1,RBD_HAS_PREFIX,RBD_PREFIX")
SET(RBD_SYNTAX ${RBD_SYNTAX} "FILES,0,-1,RBD_HAS_FILES,RBD_FILES")
SET(RBD_SYNTAX ${RBD_SYNTAX} "SUBDIRS,0,-1,RBD_HAS_SUBDIRS,RBD_SUBDIRS")
SPLIT_ARGN(${RBD_SYNTAX} ARGUMENTS ${ARGN})
#MESSAGE(STATUS "ROBOT_DATA(${RBD_NAME}): PREFIX=${RBD_PREFIX} FILES=${RBD_FILES} SUBDIRS=${RBD_SUBDIRS}")
IF(NOT RBD_HAS_NAME OR NOT RBD_NAME)
MESSAGE(FATAL_ERROR "Cannot install data for a robot module with no specified name")
ENDIF()
SET(REAL_FILES) # Reset the list (remember, it's a CMakeLists.txt global variable :-()
IF(RBD_HAS_FILES AND RBD_FILES)
IF(RBD_HAS_PREFIX AND RBD_PREFIX)
FOREACH(_FILE ${RBD_FILES})
LIST(APPEND REAL_FILES ${RBD_PREFIX}/${_FILE})
ENDFOREACH(_FILE ${RBD_FILES})
ELSE()
SET(REAL_FILES ${RBD_FILES})
ENDIF()
#MESSAGE(STATUS "Files to install(-1) for ${RBD_NAME} robot: ${REAL_FILES}")
ENDIF()
#MESSAGE(STATUS "Files to install(0) for ${RBD_NAME} robot: ${REAL_FILES}")
IF(RBD_HAS_PREFIX AND RBD_PREFIX)
LIST(APPEND REAL_FILES ${RBD_PREFIX}/${RBD_NAME}.xml)
ELSE()
LIST(APPEND REAL_FILES ${RBD_NAME}.xml)
ENDIF()
#MESSAGE(STATUS "Files to install for ${RBD_NAME} robot: ${REAL_FILES}")
SD_INSTALL_FILES(DATA drivers/${RBD_NAME} FILES ${REAL_FILES})
IF(RBD_HAS_SUBDIRS AND RBD_SUBDIRS)
IF(RBD_HAS_PREFIX AND RBD_PREFIX)
SET(REAL_SUBDIRS) # Reset the list (remember, it's a CMakeLists.txt global variable :-()
FOREACH(SUBDIR ${RBD_SUBDIRS})
LIST(APPEND REAL_SUBDIRS ${RBD_PREFIX}/${SUBDIR})
ENDFOREACH(SUBDIR ${RBD_SUBDIRS})
ELSE()
SET(REAL_SUBDIRS ${RBD_SUBDIRS})
ENDIF()
#MESSAGE(STATUS "Subdirs to install for ${RBD_NAME} robot: ${REAL_SUBDIRS}")
INSTALL(DIRECTORY ${REAL_SUBDIRS}
DESTINATION ${SD_DATADIR}/drivers/${RBD_NAME}
PATTERN ".svn" EXCLUDE
PATTERN "*.xcf*" EXCLUDE
PATTERN "*.psd" EXCLUDE)
ENDIF()
ENDMACRO(ROBOT_DATA)
# Robot project definition (module build and install, with associated data)
# Args:
# NAME : Name of the robot
# INTERFACE : Robot Windows DLL Interface description (tells about exported symbols)
# See GENERATE_ROBOT_DEF_FILE macro.
# If not specified, defaults to "LEGACY_MIN" ; not used if MODULE used
# SOURCES : List of files to use as build sources if any ; not needed if MODULE used
# PREFIX : Dir. prefix for source files/subdirs to install in the robot's data dir
# FILES : Extra (non default) files to install in the robot's data dir
# SUBDIRS : Data subdirectories to install in the robot's data dir
MACRO(ROBOT)
SET(RB_SYNTAX "NAME,1,1,RB_HAS_NAME,RB_NAME")
SET(RB_SYNTAX ${RB_SYNTAX} "INTERFACE,0,-1,RB_HAS_INTERFACE,RB_INTERFACE")
SET(RB_SYNTAX ${RB_SYNTAX} "SOURCES,0,-1,RB_HAS_SOURCES,RB_SOURCES")
SET(RB_SYNTAX ${RB_SYNTAX} "PREFIX,0,-1,RB_HAS_PREFIX,RB_PREFIX")
SET(RB_SYNTAX ${RB_SYNTAX} "FILES,0,-1,RB_HAS_FILES,RB_FILES")
SET(RB_SYNTAX ${RB_SYNTAX} "SUBDIRS,0,-1,RB_HAS_SUBDIRS,RB_SUBDIRS")
#SET(__DEBUG__ TRUE)
SPLIT_ARGN(${RB_SYNTAX} ARGUMENTS ${ARGN})
#SET(__DEBUG__ FALSE)
#MESSAGE(STATUS "ROBOT(${RB_NAME}): INTERFACE=${RB_INTERFACE} (${RB_HAS_INTERFACE}) SOURCES=${RB_SOURCES} (${RB_HAS_SOURCES}) PREFIX=${RB_PREFIX} (${RB_HAS_PREFIX}) FILES=${RB_FILES} (${RB_HAS_FILES}) SUBDIRS=${RB_SUBDIRS} (${RB_HAS_SUBDIRS})")
IF(NOT RB_HAS_NAME OR NOT RB_NAME)
MESSAGE(FATAL_ERROR "Cannot build a robot with no specified name")
ENDIF()
IF(NOT RB_HAS_SOURCES OR NOT RB_SOURCES)
MESSAGE(FATAL_ERROR "Cannot build a robot without sources")
ENDIF()
IF(RB_HAS_INTERFACE AND RB_INTERFACE)
ROBOT_MODULE(NAME ${RB_NAME} INTERFACE ${RB_INTERFACE} SOURCES ${RB_SOURCES})
ELSE()
ROBOT_MODULE(NAME ${RB_NAME} SOURCES ${RB_SOURCES})
ENDIF()
ROBOT_DATA(NAME ${RB_NAME} PREFIX ${RB_PREFIX} FILES ${RB_FILES} SUBDIRS ${RB_SUBDIRS})
ENDMACRO(ROBOT)
MACRO(ADD_INTERFACE_INCLUDEDIR)
IF(IN_SOURCETREE)
SET(INCLUDE_CANDIDATE ${SOURCE_DIR}/src/interfaces)
ELSE(IN_SOURCETREE)
SET(INCLUDE_CANDIDATE ${SD_INCLUDEDIR_ABS})
ENDIF(IN_SOURCETREE)
FIND_PATH(INTERFACE_INCLUDE_DIR raceman.h
PATHS ${INCLUDE_CANDIDATE} /usr/include /usr/local/include NO_DEFAULT_PATH)
FIND_PATH(INTERFACE_INCLUDE_DIR raceman.h
PATHS ${INCLUDE_CANDIDATE} /usr/include /usr/local/include)
IF(INTERFACE_INCLUDE_DIR)
INCLUDE_DIRECTORIES(${INTERFACE_INCLUDE_DIR})
ELSE(INTERFACE_INCLUDE_DIR)
MESSAGE(FATAL_ERROR "Cannot find interface header files")
ENDIF(INTERFACE_INCLUDE_DIR)
ENDMACRO(ADD_INTERFACE_INCLUDEDIR)
MACRO(ADD_OSSPEC_INCLUDEDIR)
IF(IN_SOURCETREE)
IF(UNIX)
SET(CANDIDATE_SPEC ${SOURCE_DIR}/src/linux)
ELSEIF(WIN32)
SET(CANDIDATE_SPEC ${SOURCE_DIR}/src/windows)
ELSE(UNIX)
SET(CANDIDATE_SPEC ${SOURCE_DIR})
ENDIF(UNIX)
ELSE(IN_SOURCETREE)
SET(CANDIDATE_SPEC ${SD_INCLUDEDIR})
ENDIF(IN_SOURCETREE)
FIND_PATH(OSSPEC_INCLUDE_DIR osspec.h
PATHS ${CANDIDATE_SPEC} /usr/include /usr/local/include
NO_DEFAULT_PATH CACHE DOC "osspec header directory")
FIND_PATH(OSSPEC_INCLUDE_DIR osspec.h
PATHS ${CANDIDATE_SPEC} /usr/include /usr/local/include
CACHE DOC "osspec header directory")
IF(OSSPEC_INCLUDE_DIR)
INCLUDE_DIRECTORIES(${OSSPEC_INCLUDE_DIR})
ELSE(OSSPEC_INCLUDE_DIR)
MESSAGE(FATAL_ERROR "Cannot find osspec header file")
ENDIF(OSSPEC_INCLUDE_DIR)
ENDMACRO(ADD_OSSPEC_INCLUDEDIR)
MACRO(ADD_SDLIB_INCLUDEDIR)
SET(SDLIB_OPTIONAL FALSE)
FOREACH(SDLIB_LIB ${ARGN})
IF(${SDLIB_LIB} STREQUAL "OPTIONAL")
SET(SDLIB_OPTIONAL TRUE)
ENDIF(${SDLIB_LIB} STREQUAL "OPTIONAL")
ENDFOREACH(SDLIB_LIB ${ARGN})
FOREACH(SDLIB_LIB ${ARGN})
SET(SDLIB_FOUND_LIB TRUE)
SET(SDLIB_EXTRA_INCLUDEDIR "")
IF(SDLIB_LIB STREQUAL "client")
IF(IN_SOURCETREE)
SET(INCLUDE_CANDIDATE ${SOURCE_DIR}/src/libs/client)
ELSE(IN_SOURCETREE)
SET(INCLUDE_CANDIDATE ${SD_INCLUDEDIR_ABS})
ENDIF(IN_SOURCETREE)
FIND_PATH(SDLIB_CLIENT_INCLUDE_DIR client.h PATHS ${INCLUDE_CANDIDATE} /usr/include /usr/local/include NO_DEFAULT_PATH)
FIND_PATH(SDLIB_CLIENT_INCLUDE_DIR client.h PATHS ${INCLUDE_CANDIDATE} /usr/include /usr/local/include)
SET(SDLIB_EXTRA_INCLUDEDIR SDLIB_CLIENT_INCLUDE_DIR)
ELSEIF(SDLIB_LIB STREQUAL "confscreens")
IF(IN_SOURCETREE)
SET(INCLUDE_CANDIDATE ${SOURCE_DIR}/src/libs/confscreens)
ELSE(IN_SOURCETREE)
SET(INCLUDE_CANDIDATE ${SD_INCLUDEDIR_ABS})
ENDIF(IN_SOURCETREE)
FIND_PATH(SDLIB_CONFSCREENS_INCLUDE_DIR confscreens.h PATHS ${INCLUDE_CANDIDATE} /usr/include /usr/local/include NO_DEFAULT_PATH)
FIND_PATH(SDLIB_CONFSCREENS_INCLUDE_DIR confscreens.h PATHS ${INCLUDE_CANDIDATE} /usr/include /usr/local/include)
SET(SDLIB_EXTRA_INCLUDEDIR SDLIB_CONFSCREENS_INCLUDE_DIR)
ELSEIF(SDLIB_LIB STREQUAL "learning")
IF(IN_SOURCETREE)
SET(INCLUDE_CANDIDATE ${SOURCE_DIR}/src/libs/learning)
ELSE(IN_SOURCETREE)
SET(INCLUDE_CANDIDATE ${SD_INCLUDEDIR_ABS})
ENDIF(IN_SOURCETREE)
FIND_PATH(SDLIB_LEARNING_INCLUDE_DIR learn_debug.h PATHS ${INCLUDE_CANDIDATE} /usr/include /usr/local/include PATH_SUFFIXES "" learning NO_DEFAULT_PATH)
FIND_PATH(SDLIB_LEARNING_INCLUDE_DIR learn_debug.h PATHS ${INCLUDE_CANDIDATE} /usr/include /usr/local/include PATH_SUFFIXES "" learning)
SET(SDLIB_EXTRA_INCLUDEDIR SDLIB_LEARNING_INCLUDE_DIR)
ELSEIF(SDLIB_LIB STREQUAL "math")
IF(IN_SOURCETREE)
SET(INCLUDE_CANDIDATE ${SOURCE_DIR}/src/libs/math)
ELSE(IN_SOURCETREE)
SET(INCLUDE_CANDIDATE ${SD_INCLUDEDIR_ABS})
ENDIF(IN_SOURCETREE)
FIND_PATH(SDLIB_MATH_INCLUDE_DIR linalg_t.h PATHS ${INCLUDE_CANDIDATE} /usr/include /usr/local/include PATH_SUFFIXES "" math tmath NO_DEFAULT_PATH)
FIND_PATH(SDLIB_MATH_INCLUDE_DIR linalg_t.h PATHS ${INCLUDE_CANDIDATE} /usr/include /usr/local/include PATH_SUFFIXES "" math tmath)
SET(SDLIB_EXTRA_INCLUDEDIR SDLIB_MATH_INCLUDE_DIR)
ELSEIF(SDLIB_LIB STREQUAL "networking")
IF(IN_SOURCETREE)
SET(INCLUDE_CANDIDATE ${SOURCE_DIR}/src/modules/networking)
ELSE(IN_SOURCETREE)
SET(INCLUDE_CANDIDATE ${SD_INCLUDEDIR_ABS})
ENDIF(IN_SOURCETREE)
FIND_PATH(SDLIB_NETWORKING_INCLUDE_DIR network.h PATHS ${INCLUDE_CANDIDATE} /usr/include /usr/local/include NO_DEFAULT_PATH)
FIND_PATH(SDLIB_NETWORKING_INCLUDE_DIR network.h PATHS ${INCLUDE_CANDIDATE} /usr/include /usr/local/include)
SET(SDLIB_EXTRA_INCLUDEDIR SDLIB_NETWORKING_INCLUDE_DIR)
ELSEIF(SDLIB_LIB STREQUAL "portability")
IF(IN_SOURCETREE)
SET(INCLUDE_CANDIDATE ${SOURCE_DIR}/src/libs/portability)
ELSE(IN_SOURCETREE)
SET(INCLUDE_CANDIDATE ${SD_INCLUDEDIR_ABS})
ENDIF(IN_SOURCETREE)
FIND_PATH(SDLIB_PORTABILITY_INCLUDE_DIR portability.h PATHS ${INCLUDE_CANDIDATE} /usr/include /usr/local/include NO_DEFAULT_PATH)
FIND_PATH(SDLIB_PORTABILITY_INCLUDE_DIR portability.h PATHS ${INCLUDE_CANDIDATE} /usr/include /usr/local/include)
SET(SDLIB_EXTRA_INCLUDEDIR SDLIB_PORTABILITY_INCLUDE_DIR)
ELSEIF(SDLIB_LIB STREQUAL "raceengineclient")
IF(IN_SOURCETREE)
SET(INCLUDE_CANDIDATE ${SOURCE_DIR}/src/libs/raceengineclient)
ELSE(IN_SOURCETREE)
SET(INCLUDE_CANDIDATE ${SD_INCLUDEDIR_ABS})
ENDIF(IN_SOURCETREE)
FIND_PATH(SDLIB_RACEENGINECLIENT_INCLUDE_DIR raceengineclient.h PATHS ${INCLUDE_CANDIDATE} /usr/include /usr/local/include NO_DEFAULT_PATH)
FIND_PATH(SDLIB_RACEENGINECLIENT_INCLUDE_DIR raceengineclient.h PATHS ${INCLUDE_CANDIDATE} /usr/include /usr/local/include)
SET(SDLIB_EXTRA_INCLUDEDIR SDLIB_RACEENGINECLIENT_INCLUDE_DIR)
ELSEIF(SDLIB_LIB STREQUAL "racescreens")
IF(IN_SOURCETREE)
SET(INCLUDE_CANDIDATE ${SOURCE_DIR}/src/libs/racescreens)
ELSE(IN_SOURCETREE)
SET(INCLUDE_CANDIDATE ${SD_INCLUDEDIR_ABS})
ENDIF(IN_SOURCETREE)
FIND_PATH(SDLIB_RACESCREENS_INCLUDE_DIR racescreens.h PATHS ${INCLUDE_CANDIDATE} /usr/include /usr/local/include NO_DEFAULT_PATH)
FIND_PATH(SDLIB_RACESCREENS_INCLUDE_DIR racescreens.h PATHS ${INCLUDE_CANDIDATE} /usr/include /usr/local/include)
SET(SDLIB_EXTRA_INCLUDEDIR SDLIB_RACESCREENS_INCLUDE_DIR)
ELSEIF(SDLIB_LIB STREQUAL "robottools")
IF(IN_SOURCETREE)
SET(INCLUDE_CANDIDATE ${SOURCE_DIR}/src/libs/robottools)
ELSE(IN_SOURCETREE)
SET(INCLUDE_CANDIDATE ${SD_INCLUDEDIR_ABS})
ENDIF(IN_SOURCETREE)
FIND_PATH(SDLIB_ROBOTTOOLS_INCLUDE_DIR robottools.h PATHS ${INCLUDE_CANDIDATE} /usr/include /usr/local/include NO_DEFAULT_PATH)
FIND_PATH(SDLIB_ROBOTTOOLS_INCLUDE_DIR robottools.h PATHS ${INCLUDE_CANDIDATE} /usr/include /usr/local/include)
SET(SDLIB_EXTRA_INCLUDEDIR SDLIB_ROBOTTOOLS_INCLUDE_DIR)
ELSEIF(SDLIB_LIB STREQUAL "tgf")
IF(IN_SOURCETREE)
SET(INCLUDE_CANDIDATE ${SOURCE_DIR}/src/libs/tgf)
ELSE(IN_SOURCETREE)
SET(INCLUDE_CANDIDATE ${SD_INCLUDEDIR_ABS})
ENDIF(IN_SOURCETREE)
FIND_PATH(SDLIB_TGF_INCLUDE_DIR tgf.h PATHS ${INCLUDE_CANDIDATE} /usr/include /usr/local/include NO_DEFAULT_PATH)
FIND_PATH(SDLIB_TGF_INCLUDE_DIR tgf.h PATHS ${INCLUDE_CANDIDATE} /usr/include /usr/local/include)
SET(SDLIB_EXTRA_INCLUDEDIR SDLIB_TGF_INCLUDE_DIR)
ELSEIF(SDLIB_LIB STREQUAL "tgfclient")
IF(IN_SOURCETREE)
SET(INCLUDE_CANDIDATE ${SOURCE_DIR}/src/libs/tgfclient)
ELSE(IN_SOURCETREE)
SET(INCLUDE_CANDIDATE ${SD_INCLUDEDIR_ABS})
ENDIF(IN_SOURCETREE)
FIND_PATH(SDLIB_TGFCLIENT_INCLUDE_DIR tgfclient.h PATHS ${INCLUDE_CANDIDATE} /usr/include /usr/local/include NO_DEFAULT_PATH)
FIND_PATH(SDLIB_TGFCLIENT_INCLUDE_DIR tgfclient.h PATHS ${INCLUDE_CANDIDATE} /usr/include /usr/local/include)
SET(SDLIB_EXTRA_INCLUDEDIR SDLIB_TGFCLIENT_INCLUDE_DIR)
ELSEIF(SDLIB_LIB STREQUAL "txml")
IF(IN_SOURCETREE)
SET(INCLUDE_CANDIDATE ${SOURCE_DIR}/src/libs/txml)
ELSE(IN_SOURCETREE)
SET(INCLUDE_CANDIDATE ${SD_INCLUDEDIR_ABS})
ENDIF(IN_SOURCETREE)
FIND_PATH(SDLIB_TXML_INCLUDE_DIR xml.h PATHS ${INCLUDE_CANDIDATE} /usr/include /usr/local/include NO_DEFAULT_PATH)
FIND_PATH(SDLIB_TXML_INCLUDE_DIR xml.h PATHS ${INCLUDE_CANDIDATE} /usr/include /usr/local/include)
SET(SDLIB_EXTRA_INCLUDEDIR SDLIB_TXML_INCLUDE_DIR)
ELSE(SDLIB_LIB STREQUAL "client")
SET(SDLIB_FOUND_LIB FALSE)
IF(NOT SDLIB_LIB STREQUAL "OPTIONAL")
MESSAGE(WARNING ": ${SDLIB_LIB} is not a Speed Dreams library")
ENDIF(NOT SDLIB_LIB STREQUAL "OPTIONAL")
ENDIF(SDLIB_LIB STREQUAL "client")
IF(SDLIB_FOUND_LIB)
IF(${SDLIB_EXTRA_INCLUDEDIR})
SET(SDLIB_INCLUDE_DIRS ${SDLIB_INCLUDE_DIRS} ${${SDLIB_EXTRA_INCLUDEDIR}})
ELSE(${SDLIB_EXTRA_INCLUDEDIR})
IF(NOT SDLIB_OPTIONAL AND NOT SDLIB_LIB STREQUAL "OPTIONAL")
MESSAGE(FATAL_ERROR "Cannot find ${SDLIB_LIB} library header files")
ENDIF(NOT SDLIB_OPTIONAL AND NOT SDLIB_LIB STREQUAL "OPTIONAL")
ENDIF(${SDLIB_EXTRA_INCLUDEDIR})
ENDIF(SDLIB_FOUND_LIB)
ENDFOREACH(SDLIB_LIB ${SDLIB_LIBS})
INCLUDE_DIRECTORIES(${SDLIB_INCLUDE_DIRS})
ENDMACRO(ADD_SDLIB_INCLUDEDIR)
MACRO(ADD_SDLIB_LIBRARY TARGET)
SET(SDLIB_OPTIONAL FALSE)
SET(SDLIB_STATIC FALSE)
SET(SDLIB_TARGET_SUFFIX "")
FOREACH(SDLIB_LIB ${ARGN})
IF(${SDLIB_LIB} STREQUAL "OPTIONAL")
SET(SDLIB_OPTIONAL TRUE)
ENDIF(${SDLIB_LIB} STREQUAL "OPTIONAL")
IF(${SDLIB_LIB} STREQUAL "STATIC")
SET(SDLIB_STATIC TRUE)
SET(SDLIB_TARGET_SUFFIX "_static")
ENDIF(${SDLIB_LIB} STREQUAL "STATIC")
ENDFOREACH(SDLIB_LIB ${ARGN})
FOREACH(SDLIB_LIB ${ARGN})
SET(SDLIB_IGNORE TRUE)
IF(NOT UNIX)
SET(SDLIB_IGNORE FALSE)
ELSEIF(NOT SDLIB_LIB STREQUAL "ssggraph" AND NOT SDLIB_LIB STREQUAL "track")
SET(SDLIB_IGNORE FALSE)
ENDIF(NOT UNIX)
IF(SDLIB_LIB STREQUAL "OPTIONAL" OR SDLIB_LIB STREQUAL "STATIC")
SET(SDLIB_IGNORE TRUE) #Ignore: not a real target
ENDIF(SDLIB_LIB STREQUAL "OPTIONAL" OR SDLIB_LIB STREQUAL "STATIC")
IF(NOT SDLIB_IGNORE)
SET(SDLIB_FOUND_LIB TRUE)
SET(SDLIB_EXTRA_LIBRARY "")
#Use IF(TARGET ${TOCSLIB_LIB}) from CMake 2.6
GET_TARGET_PROPERTY(SDLIB_TARGET_LOCATION ${SDLIB_LIB}${SDLIB_TARGET_SUFFIX} LOCATION)
IF(NOT SDLIB_TARGET_LOCATION STREQUAL "NOTFOUND")
SET(SDLIB_LIBRARIES ${SDLIB_LIBRARIES} ${SDLIB_LIB}${SDLIB_TARGET_SUFFIX})
ELSE(NOT SDLIB_TARGET_LOCATION STREQUAL "NOTFOUND")
MESSAGE(WARNING "Warning: didn't found target ${SDLIB_LIB}")
IF(SDLIB_LIB STREQUAL "client")
IF(IN_SOURCETREE)
SET(LIBRARY_CANDIDATE ${SOURCE_DIR}/src/libs/client)
ELSE(IN_SOURCETREE)
SET(LIBRARY_CANDIDATE ${SD_LIBDIR_ABS})
ENDIF(IN_SOURCETREE)
FIND_LIBRARY(SDLIB_CLIENT_LIBRARY client PATHS ${LIBRARY_CANDIDATE} /usr/lib /usr/local/lib PATH_SUFFIXES "" lib)
SET(SDLIB_EXTRA_LIBRARY SDLIB_CLIENT_LIBRARY)
ELSEIF(SDLIB_LIB STREQUAL "confscreens")
IF(IN_SOURCETREE)
SET(LIBRARY_CANDIDATE ${SOURCE_DIR}/src/libs/confscreens)
ELSE(IN_SOURCETREE)
SET(LIBRARY_CANDIDATE ${SD_LIBDIR_ABS})
ENDIF(IN_SOURCETREE)
FIND_LIBRARY(SDLIB_CONFSCREENS_LIBRARY confscreens PATHS ${LIBRARY_CANDIDATE} /usr/lib /usr/local/lib PATH_SUFFIXES "" lib)
SET(SDLIB_EXTRA_LIBRARY SDLIB_CONFSCREENS_LIBRARY)
ELSEIF(SDLIB_LIB STREQUAL "learning")
IF(IN_SOURCETREE)
SET(LIBRARY_CANDIDATE ${SOURCE_DIR}/src/libs/learning)
ELSE(IN_SOURCETREE)
SET(LIBRARY_CANDIDATE ${SD_LIBDIR_ABS})
ENDIF(IN_SOURCETREE)
FIND_LIBRARY(SDLIB_LEARNING_LIBRARY learning PATHS ${LIBRARY_CANDIDATE} /usr/lib /usr/local/lib PATH_SUFFIXES "" lib)
SET(SDLIB_EXTRA_LIBRARY SDLIB_LEARNING_LIBRARY)
ELSEIF(SDLIB_LIB STREQUAL "networking")
IF(IN_SOURCETREE)
SET(LIBRARY_CANDIDATE ${SOURCE_DIR}/src/modules/networking)
ELSE(IN_SOURCETREE)
SET(LIBRARY_CANDIDATE ${SD_LIBDIR_ABS})
ENDIF(IN_SOURCETREE)
FIND_LIBRARY(SDLIB_NETWORKING_LIBRARY learning PATHS ${LIBRARY_CANDIDATE} /usr/lib /usr/local/lib PATH_SUFFIXES "" lib)
SET(SDLIB_EXTRA_LIBRARY SDLIB_NETWORKING_LIBRARY)
ELSEIF(SDLIB_LIB STREQUAL "raceengineclient" OR SDLIB_LIB STREQUAL "raceengine")
IF(IN_SOURCETREE)
SET(LIBRARY_CANDIDATE ${SOURCE_DIR}/src/libs/raceengineclient)
ELSE(IN_SOURCETREE)
SET(LIBRARY_CANDIDATE ${SD_LIBDIR_ABS})
ENDIF(IN_SOURCETREE)
FIND_LIBRARY(SDLIB_RACEENGINECLIENT_LIBRARY raceengineclient PATHS ${LIBRARY_CANDIDATE} /usr/lib /usr/local/lib PATH_SUFFIXES "" lib)
SET(SDLIB_EXTRA_LIBRARY SDLIB_RACEENGINECLIENT_LIBRARY)
ELSEIF(SDLIB_LIB STREQUAL "racescreens")
IF(IN_SOURCETREE)
SET(LIBRARY_CANDIDATE ${SOURCE_DIR}/src/libs/racescreens)
ELSE(IN_SOURCETREE)
SET(LIBRARY_CANDIDATE ${SD_LIBDIR_ABS})
ENDIF(IN_SOURCETREE)
FIND_LIBRARY(SDLIB_RACESCREENS_LIBRARY racescreens ${LIBRARY_CANDIDATE} /usr/lib /usr/local/lib PATH_SUFFIXES "" lib)
SET(SDLIB_EXTRA_LIBRARY SDLIB_RACESCREENS_LIBRARY)
ELSEIF(SDLIB_LIB STREQUAL "robottools")
IF(IN_SOURCETREE)
SET(LIBRARY_CANDIDATE ${SOURCE_DIR}/src/libs/robottools)
ELSE(IN_SOURCETREE)
SET(LIBRARY_CANDIDATE ${SD_LIBDIR_ABS})
ENDIF(IN_SOURCETREE)
FIND_LIBRARY(SDLIB_ROBOTTOOLS_LIBRARY robottools PATHS ${LIBRARY_CANDIDATE} /usr/lib /usr/local/lib PATH_SUFFIXES "" lib)
SET(SDLIB_EXTRA_LIBRARY SDLIB_ROBOTTOOLS_LIBRARY)
ELSEIF(SDLIB_LIB STREQUAL "tgf")
IF(IN_SOURCETREE)
SET(LIBRARY_CANDIDATE ${SOURCE_DIR}/src/libs/tgf)
ELSE(IN_SOURCETREE)
SET(LIBRARY_CANDIDATE ${SD_LIBDIR_ABS})
ENDIF(IN_SOURCETREE)
FIND_LIBRARY(SDLIB_TGF_LIBRARY tgf${SDLIB_TARGET_SUFFIX} PATHS ${LIBRARY_CANDIDATE} /usr/lib /usr/local/lib
PATH_SUFFIXES "" lib)
SET(SDLIB_EXTRA_LIBRARY SDLIB_TGF_LIBRARY)
ELSEIF(SDLIB_LIB STREQUAL "tgfclient")
IF(IN_SOURCETREE)
SET(LIBRARY_CANDIDATE ${SOURCE_DIR}/src/libs/tgfclient)
ELSE(IN_SOURCETREE)
SET(LIBRARY_CANDIDATE ${SD_LIBDIR_ABS})
ENDIF(IN_SOURCETREE)
FIND_LIBRARY(SDLIB_TGFCLIENT_LIBRARY tgfclient PATHS ${LIBRARY_CANDIDATE} /usr/lib /usr/local/lib PATH_SUFFIXES "" lib)
SET(SDLIB_EXTRA_LIBRARY SDLIB_TGFCLIENT_LIBRARY)
ELSEIF(SDLIB_LIB STREQUAL "txml")
IF(IN_SOURCETREE)
SET(LIBRARY_CANDIDATE ${SOURCE_DIR}/src/libs/txml)
ELSE(IN_SOURCETREE)
SET(LIBRARY_CANDIDATE ${SD_LIBDIR_ABS})
ENDIF(IN_SOURCETREE)
FIND_LIBRARY(SDLIB_TXML_LIBRARY txml${SDLIB_TARGET_SUFFIX} PATHS ${LIBRARY_CANDIDATE} /usr/lib /usr/local/lib
PATH_SUFFIXES "" lib)
SET(SDLIB_EXTRA_LIBRARY SDLIB_TXML_LIBRARY)
ELSEIF(SDLIB_LIB STREQUAL "ssggraph")
IF(IN_SOURCETREE)
SET(LIBRARY_CANDIDATE ${SOURCE_DIR}/src/modules/graphic/ssggraph)
ELSE(IN_SOURCETREE)
SET(LIBRARY_CANDIDATE ${SD_LIBDIR_ABS})
ENDIF(IN_SOURCETREE)
FIND_LIBRARY(SDLIB_SSGGRAPH_LIBRARY ssggraph PATHS ${LIBRARY_CANDIDATE} /usr/lib /usr/local/lib PATH_SUFFIXES "" lib)
SET(SDLIB_EXTRA_LIBRARY SDLIB_SSGGRAPH_LIBRARY)
ELSEIF(SDLIB_LIB STREQUAL "track")
IF(IN_SOURCETREE)
SET(LIBRARY_CANDIDATE ${SOURCE_DIR}/src/modules/track)
ELSE(IN_SOURCETREE)
SET(LIBRARY_CANDIDATE ${SD_LIBDIR_ABS})
ENDIF(IN_SOURCETREE)
FIND_LIBRARY(SDLIB_TRACK_LIBRARY track PATHS ${LIBRARY_CANDIDATE} /usr/lib /usr/local/lib PATH_SUFFIXES "" lib)
SET(SDLIB_EXTRA_LIBRARY SDLIB_TRACK_LIBRARY)
ELSE(SDLIB_LIB STREQUAL "client")
SET(SDLIB_FOUND_LIB FALSE)
IF(NOT SDLIB_LIB STREQUAL "OPTIONAL" AND NOT SDLIB_LIB STREQUAL "STATIC")
MESSAGE(WARNING ": ${SDLIB_LIB} is not a Speed Dreams library")
ENDIF(NOT SDLIB_LIB STREQUAL "OPTIONAL" AND NOT SDLIB_LIB STREQUAL "STATIC")
ENDIF(SDLIB_LIB STREQUAL "client")
IF(SDLIB_FOUND_LIB)
IF(${SDLIB_EXTRA_LIBRARY})
SET(SDLIB_LIBRARIES ${SDLIB_LIBRARIES} ${${SDLIB_EXTRA_LIBRARY}})
ELSE(${SDLIB_EXTRA_LIBRARY})
IF(NOT SDLIB_OPTIONAL AND NOT SDLIB_LIB STREQUAL "OPTIONAL" AND NOT SDLIB_LIB STREQUAL "STATIC")
MESSAGE(FATAL_ERROR "Cannot find ${SDLIB_LIB} library shared object")
ENDIF(NOT SDLIB_OPTIONAL AND NOT SDLIB_LIB STREQUAL "OPTIONAL" AND NOT SDLIB_LIB STREQUAL "STATIC")
ENDIF(${SDLIB_EXTRA_LIBRARY})
ENDIF(SDLIB_FOUND_LIB)
ENDIF(NOT SDLIB_TARGET_LOCATION STREQUAL "NOTFOUND")
ENDIF(NOT SDLIB_IGNORE)
ENDFOREACH(SDLIB_LIB ${SDLIB_LIBS})
TARGET_LINK_LIBRARIES(${TARGET} ${SDLIB_LIBRARIES})
ENDMACRO(ADD_SDLIB_LIBRARY TARGET)
MACRO(ADD_PLIB_INCLUDEDIR)
FIND_PACKAGE(PLIB)
IF(PLIB_FOUND)
INCLUDE_DIRECTORIES(${PLIB_INCLUDE_DIR})
ELSE(PLIB_FOUND)
MESSAGE(FATAL_ERROR "Cannot find plib header files")
ENDIF(PLIB_FOUND)
ENDMACRO(ADD_PLIB_INCLUDEDIR)
MACRO(ADD_PLIB_LIBRARY TARGET)
FIND_PACKAGE(PLIB)
IF(NOT PLIB_FOUND)
MESSAGE(FATAL_ERROR "Cannot find plib")
ENDIF(NOT PLIB_FOUND)
IF(NOT APPLE)
FOREACH(PLIB_LIB ${ARGN})
IF(PLIB_LIB STREQUAL "ul")
SET(PLIB_LIBRARIES ${PLIB_LIBRARIES} ${PLIB_UL_LIBRARY})
ELSEIF(PLIB_LIB STREQUAL "js")
SET(PLIB_LIBRARIES ${PLIB_LIBRARIES} ${PLIB_JS_LIBRARY})
ELSEIF(PLIB_LIB STREQUAL "sg")
SET(PLIB_LIBRARIES ${PLIB_LIBRARIES} ${PLIB_SG_LIBRARY})
ELSEIF(PLIB_LIB STREQUAL "sl")
SET(PLIB_LIBRARIES ${PLIB_LIBRARIES} ${PLIB_SL_LIBRARY})
ELSEIF(PLIB_LIB STREQUAL "sm")
SET(PLIB_LIBRARIES ${PLIB_LIBRARIES} ${PLIB_SM_LIBRARY})
ELSEIF(PLIB_LIB STREQUAL "ssg")
SET(PLIB_LIBRARIES ${PLIB_LIBRARIES} ${PLIB_SSG_LIBRARY})
ELSEIF(PLIB_LIB STREQUAL "ssgaux")
SET(PLIB_LIBRARIES ${PLIB_LIBRARIES} ${PLIB_SSGAUX_LIBRARY})
ELSE(PLIB_LIB STREQUAL "ul")
MESSAGE(WARNING "${PLIB_LIB} is not part of plib")
ENDIF(PLIB_LIB STREQUAL "ul")
ENDFOREACH(PLIB_LIB ${ARGN})
ENDIF(NOT APPLE)
#Special case apple only uses one library
IF(APPLE)
SET(PLIB_LIBRARIES ${PLIB_LIBRARIES} ${PLIB_APPLE_LIBRARY})
ENDIF(APPLE)
TARGET_LINK_LIBRARIES(${TARGET} ${PLIB_LIBRARIES})
ENDMACRO(ADD_PLIB_LIBRARY TARGET)
MACRO(ADD_SDL_INCLUDEDIR)
FIND_PACKAGE(SDL)
IF(SDL_FOUND)
INCLUDE_DIRECTORIES(${SDL_INCLUDE_DIR})
ELSE(SDL_FOUND)
MESSAGE(FATAL_ERROR "Cannot find SDL header files")
ENDIF(SDL_FOUND)
ENDMACRO(ADD_SDL_INCLUDEDIR)
MACRO(ADD_SDL_LIBRARY TARGET)
FIND_PACKAGE(SDL)
IF(SDL_FOUND)
TARGET_LINK_LIBRARIES(${TARGET} ${SDL_LIBRARY})
IF(SDLMAIN_LIBRARY)
TARGET_LINK_LIBRARIES(${TARGET} ${SDLMAIN_LIBRARY})
ENDIF(SDLMAIN_LIBRARY)
ELSE(SDL_FOUND)
MESSAGE(FATAL_ERROR "Cannot find SDL library")
ENDIF(SDL_FOUND)
ENDMACRO(ADD_SDL_LIBRARY TARGET)
MACRO(ADD_OPENGL_INCLUDEDIR)
FIND_PACKAGE(OpenGL)
IF(OPENGL_FOUND)
INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR})
ELSE(OPENGL_FOUND)
MESSAGE(FATAL_ERROR "Cannot find OpenGL header files")
ENDIF(OPENGL_FOUND)
ENDMACRO(ADD_OPENGL_INCLUDEDIR)
MACRO(ADD_OPENGL_LIBRARY TARGET)
FIND_PACKAGE(OpenGL)
IF(OPENGL_FOUND)
TARGET_LINK_LIBRARIES(${TARGET} ${OPENGL_LIBRARIES})
ELSE(OPENGL_FOUND)
MESSAGE(FATAL_ERROR "Cannot find OpenGL libraries")
ENDIF(OPENGL_FOUND)
ENDMACRO(ADD_OPENGL_LIBRARY TARGET)
MACRO(ADD_OPENAL_INCLUDEDIR)
FIND_PACKAGE(OpenAL)
IF(OPENAL_FOUND)
INCLUDE_DIRECTORIES(${OPENAL_INCLUDE_DIR})
ELSE(OPENAL_FOUND)
MESSAGE(FATAL_ERROR "Cannot find OpenAL header files")
ENDIF(OPENAL_FOUND)
ENDMACRO(ADD_OPENAL_INCLUDEDIR)
MACRO(ADD_OPENAL_LIBRARY TARGET)
FIND_PACKAGE(OpenAL)
IF(OPENAL_FOUND)
TARGET_LINK_LIBRARIES(${TARGET} ${OPENAL_LIBRARIES})
ELSE(OPENAL_FOUND)
MESSAGE(FATAL_ERROR "Cannot find OpenAL libraries")
ENDIF(OPENAL_FOUND)
ENDMACRO(ADD_OPENAL_LIBRARY TARGET)
MACRO(ADD_ENET_INCLUDEDIR)
FIND_PACKAGE(ENET)
IF(ENET_FOUND)
INCLUDE_DIRECTORIES(${ENET_INCLUDE_DIR})
ELSE(ENET_FOUND)
MESSAGE(FATAL_ERROR "Cannot find ENET header files")
ENDIF(ENET_FOUND)
ENDMACRO(ADD_ENET_INCLUDEDIR)
MACRO(ADD_ENET_LIBRARY TARGET)
FIND_PACKAGE(ENET)
IF(ENET_FOUND)
TARGET_LINK_LIBRARIES(${TARGET} ${ENET_LIBRARY})
ELSE(ENET_FOUND)
MESSAGE(FATAL_ERROR "Cannot find ENET libraries")
ENDIF(ENET_FOUND)
ENDMACRO(ADD_ENET_LIBRARY TARGET)
MACRO(ADD_PNG_INCLUDEDIR)
FIND_PACKAGE(PNG)
IF(PNG_FOUND)
INCLUDE_DIRECTORIES(${PNG_INCLUDE_DIR})
ELSE(PNG_FOUND)
MESSAGE(FATAL_ERROR "Cannot find PNG header files")
ENDIF(PNG_FOUND)
ENDMACRO(ADD_PNG_INCLUDEDIR)
MACRO(ADD_PNG_LIBRARY TARGET)
FIND_PACKAGE(PNG)
IF(PNG_FOUND)
TARGET_LINK_LIBRARIES(${TARGET} ${PNG_LIBRARIES})
ELSE(PNG_FOUND)
MESSAGE(FATAL_ERROR "Cannot find PNG libraries")
ENDIF(PNG_FOUND)
ENDMACRO(ADD_PNG_LIBRARY TARGET)
MACRO(ADD_JPEG_INCLUDEDIR)
FIND_PACKAGE(JPEG)
IF(JPEG_FOUND)
INCLUDE_DIRECTORIES(${JPEG_INCLUDE_DIR})
ELSE(JPEG_FOUND)
MESSAGE(FATAL_ERROR "Cannot find JPEG header files")
ENDIF(JPEG_FOUND)
ENDMACRO(ADD_JPEG_INCLUDEDIR)
MACRO(ADD_JPEG_LIBRARY TARGET)
FIND_PACKAGE(JPEG)
IF(JPEG_FOUND)
TARGET_LINK_LIBRARIES(${TARGET} ${JPEG_LIBRARIES})
ELSE(JPEG_FOUND)
MESSAGE(FATAL_ERROR "Cannot find JPEG libraries")
ENDIF(JPEG_FOUND)
ENDMACRO(ADD_JPEG_LIBRARY TARGET)
MACRO(ADD_X11_INCLUDEDIR)
FIND_PACKAGE(X11)
IF(X11_FOUND)
INCLUDE_DIRECTORIES(${X11_INCLUDE_DIR})
MESSAGE(STATUS "INCLUDED ${X11_INCLUDE_DIR}")
ELSE(X11_FOUND)
MESSAGE(FATAL_ERROR "Cannot find X11 header files")
ENDIF(X11_FOUND)
ENDMACRO(ADD_X11_INCLUDEDIR)
MACRO(ADD_X11_LIBRARY TARGET)
FIND_PACKAGE(X11)
IF(X11_FOUND)
TARGET_LINK_LIBRARIES(${TARGET} ${X11_LIBRARIES})
ELSE(X11_FOUND)
MESSAGE(FATAL_ERROR "Cannot find X11 libraries")
ENDIF(X11_FOUND)
ENDMACRO(ADD_X11_LIBRARY TARGET)
MACRO(ADD_XRANDR_INCLUDEDIR)
FIND_PACKAGE(X11)
FIND_PATH(X11_Xrandr_INCLUDE_PATH X11/extensions/Xrandr.h ${X11_INC_SEARCH_PATH})
IF(X11_Xrandr_INCLUDE_PATH)
INCLUDE_DIRECTORIES(${X11_Xrandr_INCLUDE_PATH} ${X11_INCLUDE_DIR})
SET(HAVE_XRANDR TRUE)
ELSE(X11_Xrandr_INCLUDE_PATH)
SET(HAVE_XRANDR FALSE)
ENDIF(X11_Xrandr_INCLUDE_PATH)
ENDMACRO(ADD_XRANDR_INCLUDEDIR)
MACRO(ADD_XRANDR_LIBRARY TARGET)
FIND_PACKAGE(X11)
FIND_LIBRARY(X11_Xrandr_LIB Xrandr ${X11_LIB_SEARCH_PATH})
IF(X11_Xrandr_LIB)
TARGET_LINK_LIBRARIES(${TARGET} ${X11_Xrandr_LIB})
SET(HAVE_XRANDR TRUE)
ELSE(X11_Xrandr_LIB)
SET(HAVE_XRANDR FALSE)
ENDIF(X11_Xrandr_LIB)
ENDMACRO(ADD_XRANDR_LIBRARY TARGET)
#Some unix compilers need libdl
MACRO(ADD_DL_LIBRARY TARGET)
IF(UNIX)
FIND_LIBRARY(LIBDL_LIB dl "")
IF(LIBDL_LIB)
TARGET_LINK_LIBRARIES(${TARGET} ${LIBDL_LIB})
ENDIF(LIBDL_LIB)
MESSAGE(STATUS LIBDL = ${LIBDL_LIB})
ENDIF(UNIX)
ENDMACRO(ADD_DL_LIBRARY TARGET)
MACRO(ADD_SD_DEFINITIONS)
IF(HAVE_CONFIG_H)
ADD_DEFINITIONS(-DHAVE_CONFIG_H)
IF(IN_SOURCETREE)
SET(INCLUDE_CANDIDATE ${SOURCE_DIR})
ELSE(IN_SOURCETREE)
SET(INCLUDE_CANDIDATE "")
ENDIF(IN_SOURCETREE)
FIND_PATH(CONFIGH_INCLUDE_DIR config.h ${INCLUDE_CANDIDATE} /usr/include /usr/local/include NO_DEFAULT_PATH)
FIND_PATH(CONFIGH_INCLUDE_DIR config.h ${INCLUDE_CANDIDATE} /usr/include /usr/local/include)
IF(CONFIGH_INCLUDE_DIR)
INCLUDE_DIRECTORIES(${CONFIGH_INCLUDE_DIR})
ELSE(CONFIGH_INCLUDE_DIR)
MESSAGE(FATAL_ERROR "Cannot find config.h header file")
ENDIF(CONFIGH_INCLUDE_DIR)
ENDIF(HAVE_CONFIG_H)
# CMake options.
SET(OPTION_OFFICIAL_ONLY false CACHE BOOL "Build / install only officially released contents)")
SET(OPTION_DEBUG true CACHE BOOL "Enable traces into the console or log file")
SET(OPTION_TRACE_LEVEL "5" CACHE STRING "Trace level integer threshold, only if OPTION_DEBUG (traces with higher level are not logged ; 0=Fatal, 1=Error, 2=Warning, 3=Info, 4=Trace, 5=Debug, ...)")
SET(OPTION_PROFILER false CACHE BOOL "Enable profiler")
SET(OPTION_SCHEDULE_SPY false CACHE BOOL "Enable fine grained scheduling spy")
IF(UNIX)
SET(OPTION_XRANDR true CACHE BOOL "XrandR")
SET(OPTION_GLEXTPROTOTYPES true CACHE BOOL "Enable prototypes in glext.h")
ENDIF(UNIX)
# Compiler definitions.
ADD_DEFINITIONS(-D_SVID_SOURCE -D_BSD_SOURCE -DSHM)
IF(WIN32)
#suppress meaningless warning for MSVC
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS)
ENDIF(WIN32)
if(OPTION_DEBUG)
ADD_DEFINITIONS(-DDEBUG -DTRACE_OUT)
ENDIF(OPTION_DEBUG)
if(OPTION_TRACE_LEVEL)
ADD_DEFINITIONS(-DTRACE_LEVEL=${OPTION_TRACE_LEVEL})
ENDIF(OPTION_TRACE_LEVEL)
IF(OPTION_XRANDR)
ADD_DEFINITIONS(-DUSE_RANDR_EXT)
ENDIF(OPTION_XRANDR)
IF(OPTION_PROFILER)
ADD_DEFINITIONS(-DPROFILER)
ENDIF(OPTION_PROFILER)
IF(OPTION_SCHEDULE_SPY)
ADD_DEFINITIONS(-DSCHEDULE_SPY)
ENDIF(OPTION_SCHEDULE_SPY)
IF(OPTION_GLEXTPROTOTYPES)
ADD_DEFINITIONS(-DGL_GLEXT_PROTOTYPES)
ENDIF(OPTION_GLEXTPROTOTYPES)
# Define for code that needs Torcs backward compatibility
ADD_DEFINITIONS(-DSPEED_DREAMS)
ENDMACRO(ADD_SD_DEFINITIONS)
MACRO(SD_INSTALL_CAR carname)
SET(files ${carname}.xml ${ARGN})
FILE(GLOB files_acc *.acc)
FILE(GLOB files_rgb *.rgb)
FILE(GLOB files_png *.png)
FILE(GLOB files_jpg *.jpg)
FILE(GLOB files_wav *.wav)
SET(files ${files} ${files_acc} ${files_rgb} ${files_png} ${files_jpg} ${files_wav})
SD_INSTALL_FILES(DATA cars/${carname} FILES ${files})
ENDMACRO(SD_INSTALL_CAR carname)
MACRO(SD_INSTALL_TRACK trackname category)
SET(files ${trackname}.xml ${ARGN})
FILE(GLOB files_png *.png)
FILE(GLOB files_rgb *.rgb)
FILE(GLOB files_ac *.ac)
FILE(GLOB files_acc *.acc)
SET(files ${files} ${files_png} ${files_rgb} ${files_ac} ${files_acc})
SD_INSTALL_FILES(DATA tracks/${category}/${trackname} FILES ${files})
ENDMACRO(SD_INSTALL_TRACK trackname category)
#Usage:
# SD_INSTALL_FILES(DATA drivers/bt FILES bt.xml logo.rgb)
# Installs the files quickrace.xml and endrace.xml in ${prefix}/share/games/speed-dreams/drivers/bt
# SD_INSTALL_FILES(DATA config/raceman USER config/raceman FILES quickrace.xml endrace.xml)
# Installs the files quickrace.xml and endrace.xml in ${prefix}/share/games/speed-dreams/drivers/bt
# and copies the file to the users home directory ~/.speed-dreams/config/raceman at startup.
# SD_INSTALL_FILES(LIB drivers/bt TARGETS bt.so)
# Installs the files bt.so in ${prefix}/lib/speed-dreams/drivers/bt
# SD_INSTALL_FILES(BIN TARGETS speed-dreams)
# Installs the speed-dreams target to the bin-directory
MACRO(SD_INSTALL_FILES)
SET(SD_INSTALL_FILES_SYNTAX "DATA,1,1,IS_DATA,DATA_PATH")
SET(SD_INSTALL_FILES_SYNTAX ${SD_INSTALL_FILES_SYNTAX} "LIB,1,1,IS_LIB,LIB_PATH")
SET(SD_INSTALL_FILES_SYNTAX ${SD_INSTALL_FILES_SYNTAX} "BIN,0,0,IS_BIN,BIN_PATH")
SET(SD_INSTALL_FILES_SYNTAX ${SD_INSTALL_FILES_SYNTAX} "INCLUDE,0,1,IS_INCLUDE,INCLUDE_PATH")
SET(SD_INSTALL_FILES_SYNTAX ${SD_INSTALL_FILES_SYNTAX} "USER,1,1,IS_USER,USER_PATH")
SET(SD_INSTALL_FILES_SYNTAX ${SD_INSTALL_FILES_SYNTAX} "FILES,0,-1,HAS_FILES,FILES")
SET(SD_INSTALL_FILES_SYNTAX ${SD_INSTALL_FILES_SYNTAX} "TARGETS,0,-1,HAS_TARGETS,TARGET_LIST")
SPLIT_ARGN(${SD_INSTALL_FILES_SYNTAX} ARGUMENTS ${ARGN})
IF(NOT IS_DATA AND NOT IS_LIB AND NOT IS_BIN AND NOT IS_INCLUDE)
MESSAGE(ERROR "Expected either LIB, DATA or BIN in SD_INSTALL_FILES")
ENDIF(NOT IS_DATA AND NOT IS_LIB AND NOT IS_BIN AND NOT IS_INCLUDE)
IF(IS_LIB)
SET(DEST1 ${SD_LIBDIR})
SET(DEST2 ${LIB_PATH})
ELSEIF(IS_DATA)
SET(DEST1 ${SD_DATADIR})
SET(DEST2 ${DATA_PATH})
ELSEIF(IS_BIN)
SET(DEST1 ${SD_BINDIR})
SET(DEST2 "")
ELSEIF(IS_INCLUDE)
SET(DEST1 ${SD_INCLUDEDIR})
SET(DEST2 "${INCLUDE_PATH}")
ELSE(IS_LIB)
MESSAGE(WARNING "SD_INSTALL_FILES called without DATA, LIB, BIN or INCLUDE command")
ENDIF(IS_LIB)
IF(DEST2 STREQUAL "" OR DEST2 STREQUAL ".")
SET(DEST2 "")
SET(DEST_ALL "${DEST1}")
ELSE(DEST2 STREQUAL "" OR DEST2 STREQUAL ".")
SET(DEST_ALL "${DEST1}/${DEST2}")
ENDIF(DEST2 STREQUAL "" OR DEST2 STREQUAL ".")
#Install files
IF(HAS_FILES)
INSTALL(FILES ${FILES} DESTINATION ${DEST_ALL})
ENDIF(HAS_FILES)
IF(HAS_TARGETS)
INSTALL(TARGETS ${TARGET_LIST} DESTINATION ${DEST_ALL})
ENDIF(HAS_TARGETS)
#Loop through all the files which must be installed
IF(IS_USER)
FOREACH(XML_FILE ${FILES})
# Get the filename
GET_FILENAME_COMPONENT(XMLFILENAME ${XML_FILE} NAME)
# Execute xmlversion to register the file as to be installed / updated at run-time
# in the user settings folder.
IF(WIN32)
GET_TARGET_PROPERTY(TXML_LIB txml LOCATION)
GET_TARGET_PROPERTY(TGF_LIB tgf LOCATION)
FIND_PACKAGE(SDL)
GET_FILENAME_COMPONENT(SDL_LIBPATH ${SDL_LIBRARY} PATH)
GET_FILENAME_COMPONENT(SDL_LIBNAME ${SDL_LIBRARY} NAME_WE)
SET(SDL_LIB ${SDL_LIBPATH}/../bin/${CMAKE_SHARED_LIBRARY_PREFIX}${SDL_LIBNAME}${CMAKE_SHARED_LIBRARY_SUFFIX})
INSTALL(CODE
"FILE(READ ${CMAKE_BINARY_DIR}/xmlversion_loc.txt XMLVERSION_EXE)
STRING(REPLACE \"$(OutDir)\" \"\${CMAKE_INSTALL_CONFIG_NAME}\" XMLVERSION_EXE \${XMLVERSION_EXE})
GET_FILENAME_COMPONENT(XMLVERSION_DIR \${XMLVERSION_EXE} PATH)
SET(TXML_LIB ${TXML_LIB})
STRING(REPLACE \"$(OutDir)\" \"\${CMAKE_INSTALL_CONFIG_NAME}\" TXML_LIB \${TXML_LIB})
SET(TGF_LIB ${TGF_LIB})
STRING(REPLACE \"$(OutDir)\" \"\${CMAKE_INSTALL_CONFIG_NAME}\" TGF_LIB \${TGF_LIB})
FILE(INSTALL DESTINATION \${XMLVERSION_DIR} TYPE FILE FILES \${TXML_LIB} \${TGF_LIB} \"${SDL_LIB}\")
SET(SD_DATADIR_ABS \"${SD_DATADIR}\")
IF(NOT IS_ABSOLUTE \${SD_DATADIR_ABS})
GET_FILENAME_COMPONENT(SD_DATADIR_ABS \"\${CMAKE_INSTALL_PREFIX}/\${SD_DATADIR_ABS}\" ABSOLUTE)
ENDIF()
EXECUTE_PROCESS(COMMAND \"\${XMLVERSION_EXE}\" \"\${SD_DATADIR_ABS}/version.xml\" \"${DATA_PATH}/${XMLFILENAME}\" \"${USER_PATH}/${XMLFILENAME}\" \"\${SD_DATADIR_ABS}\" RESULT_VARIABLE XMLVERSTATUS)
IF(XMLVERSTATUS)
MESSAGE(FATAL_ERROR \"ERROR: xmlversion failed\")
ENDIF(XMLVERSTATUS)")
ELSE(WIN32)
INSTALL(CODE
"FILE(READ ${CMAKE_BINARY_DIR}/xmlversion_loc.txt XMLVERSION_EXE)
SET(SD_DATADIR_ABS \"${SD_DATADIR}\")
IF(NOT IS_ABSOLUTE \${SD_DATADIR_ABS})
GET_FILENAME_COMPONENT(SD_DATADIR_ABS \"\${CMAKE_INSTALL_PREFIX}/\${SD_DATADIR_ABS}\" ABSOLUTE)
ENDIF()
# Why this path correction here ? This needs a comment !
SET(CUR_DESTDIR \"\$ENV{DESTDIR}\")
IF(CUR_DESTDIR MATCHES \"[^/]\")
STRING(REGEX REPLACE \"^(.*[^/])/*$\" \"\\\\1\" CUR_DESTDIR_CORR \"\${CUR_DESTDIR}\")
ELSE(CUR_DESTDIR MATCHES \"[^/]\")
SET(CUR_DESTDIR_CORR \"\")
ENDIF(CUR_DESTDIR MATCHES \"[^/]\")
EXECUTE_PROCESS(COMMAND \"\${XMLVERSION_EXE}\" \"\${CUR_DESTDIR_CORR}\${SD_DATADIR_ABS}/version.xml\" \"${DATA_PATH}/${XMLFILENAME}\" \"${USER_PATH}/${XMLFILENAME}\" \"\${CUR_DESTDIR_CORR}\${SD_DATADIR_ABS}\" RESULT_VARIABLE XMLVERSTATUS)
IF(XMLVERSTATUS)
MESSAGE(FATAL_ERROR \"ERROR: xmlversion failed\")
ENDIF(XMLVERSTATUS)")
ENDIF(WIN32)
ENDFOREACH(XML_FILE ${FILES})
ENDIF(IS_USER)
ENDMACRO(SD_INSTALL_FILES)
IF(IN_SOURCETREE)
MACRO(INSTALL_SD_CMAKE)
INSTALL(CODE
"SET(CUR_DESTDIR \"\$ENV{DESTDIR}\")
IF(CUR_DESTDIR MATCHES \"[^/]\")
STRING(REGEX REPLACE \"^(.*[^/])/*$\" \"\\\\1\" CUR_DESTDIR_CORR \"\${CUR_DESTDIR}\")
ELSE(CUR_DESTDIR MATCHES \"[^/]\")
SET(CUR_DESTDIR_CORR \"\")
ENDIF(CUR_DESTDIR MATCHES \"[^/]\")
FILE(MAKE_DIRECTORY \"\${CUR_DESTDIR_CORR}${SD_DATADIR_ABS}/cmake\")
FILE(WRITE \"\${CUR_DESTDIR_CORR}${SD_DATADIR_ABS}/cmake/speed-dreams.cmake\"
\"SET(SD_DATADIR_ABS \\\"${SD_DATADIR_ABS}\\\")
SET(SD_LOCALDIR \\\"${SD_LOCALDIR}\\\")
SET(SD_LIBDIR_ABS \\\"${SD_LIBDIR_ABS}\\\")
SET(SD_BINDIR_ABS \\\"${SD_BINDIR_ABS}\\\")
SET(SD_INCLUDEDIR_ABS \\\"${SD_INCLUDEDIR_ABS}\\\")
SET(IN_SOURCETREE FALSE)\\n\\n\")
FILE(READ \"${SOURCE_DIR}/cmake/macros.cmake\" SD_MACRO_CONTENT)
FILE(APPEND \"\${CUR_DESTDIR_CORR}${SD_DATADIR_ABS}/cmake/speed-dreams.cmake\" \${SD_MACRO_CONTENT})")
ENDMACRO(INSTALL_SD_CMAKE)
ENDIF(IN_SOURCETREE)
# Generate clobber.sh/bat shell script (remove _any_ build system generated file)
MACRO(SD_GENERATE_CLOBBER_SCRIPT)
IF(IN_SOURCETREE)
IF(WIN32)
SET(TGT_SCRIPT "${SOURCE_DIR}/clobber.bat")
FILE(WRITE "${TGT_SCRIPT}" "@echo off\n")
FILE(APPEND "${TGT_SCRIPT}" "rem CMake-generated script for in-source build tree total cleanup\n")
FILE(APPEND "${TGT_SCRIPT}" "rem (remove any build-system-generated file (+ .bak, *~, ... etc), \n")
FILE(APPEND "${TGT_SCRIPT}" "rem in case you want to get back to something like\n")
FILE(APPEND "${TGT_SCRIPT}" "rem right after a 'svn checkout' command).\n")
FILE(APPEND "${TGT_SCRIPT}" "\n")
FILE(APPEND "${TGT_SCRIPT}" "rem Check if we are on top of a CMake-enabled SD source tree\n")
FILE(APPEND "${TGT_SCRIPT}" "if not exist CMakeLists.txt goto ERROR\n")
FILE(APPEND "${TGT_SCRIPT}" "if not exist credits.xml goto ERROR\n")
FILE(APPEND "${TGT_SCRIPT}" "if not exist cmake goto ERROR\n")
FILE(APPEND "${TGT_SCRIPT}" "if not exist data goto ERROR\n")
FILE(APPEND "${TGT_SCRIPT}" "if not exist src goto ERROR\n")
FILE(APPEND "${TGT_SCRIPT}" "\n")
FILE(APPEND "${TGT_SCRIPT}" "echo Cleaning up in-source build tree ...\n")
FILE(APPEND "${TGT_SCRIPT}" "\n")
FILE(APPEND "${TGT_SCRIPT}" "rem CMake generated files and dirs\n")
FILE(APPEND "${TGT_SCRIPT}" "\n")
FILE(APPEND "${TGT_SCRIPT}" "del CMakeCache.txt\n")
FILE(APPEND "${TGT_SCRIPT}" "del config.h\n")
FILE(APPEND "${TGT_SCRIPT}" "del CPackConfig.cmake\n")
FILE(APPEND "${TGT_SCRIPT}" "del CPackSourceConfig.cmake\n")
FILE(APPEND "${TGT_SCRIPT}" "del uninstall.cmake\n")
FILE(APPEND "${TGT_SCRIPT}" "del doxygen_config\n")
FILE(APPEND "${TGT_SCRIPT}" "del install_manifest.txt\n")
FILE(APPEND "${TGT_SCRIPT}" "del speed-dreams.ncb\n")
FILE(APPEND "${TGT_SCRIPT}" "del /ah speed-dreams.suo\n")
FILE(APPEND "${TGT_SCRIPT}" "del speed-dreams.sln\n")
FILE(APPEND "${TGT_SCRIPT}" "del version.h\n")
FILE(APPEND "${TGT_SCRIPT}" "del xmlversion_loc.txt\n")
FILE(APPEND "${TGT_SCRIPT}" "del /s /q *.vcproj*\n")
FILE(APPEND "${TGT_SCRIPT}" "del /s /q cmake_install.cmake\n")
FILE(APPEND "${TGT_SCRIPT}" "for /f \"tokens=*\" %%G in ('dir /b /ad /s CMakeFiles*') do rmdir /s /q %%G\n")
FILE(APPEND "${TGT_SCRIPT}" "for /f \"tokens=*\" %%G in ('dir /b /ad /s *.dir') do rmdir /s /q %%G\n")
FILE(APPEND "${TGT_SCRIPT}" "for /f \"tokens=*\" %%G in ('dir /b /ad /s Debug*') do rmdir /s /q %%G\n")
FILE(APPEND "${TGT_SCRIPT}" "for /f \"tokens=*\" %%G in ('dir /b /ad /s Release*') do rmdir /s /q %%G\n")
FILE(APPEND "${TGT_SCRIPT}" "rmdir /s /q _CPack_Packages\n")
FILE(APPEND "${TGT_SCRIPT}" "\n")
FILE(APPEND "${TGT_SCRIPT}" "rem Other useless files\n")
FILE(APPEND "${TGT_SCRIPT}" "del /s /q *.*~\n")
FILE(APPEND "${TGT_SCRIPT}" "del /s /q *.~*\n")
FILE(APPEND "${TGT_SCRIPT}" "del /s /q *.bak\n")
FILE(APPEND "${TGT_SCRIPT}" "del /s /q *.flc\n")
FILE(APPEND "${TGT_SCRIPT}" "del /s /q *.orig\n")
FILE(APPEND "${TGT_SCRIPT}" "\n")
FILE(APPEND "${TGT_SCRIPT}" "echo Done.\n")
FILE(APPEND "${TGT_SCRIPT}" "\n")
FILE(APPEND "${TGT_SCRIPT}" "goto END\n")
FILE(APPEND "${TGT_SCRIPT}" "\n")
FILE(APPEND "${TGT_SCRIPT}" ":ERROR\n")
FILE(APPEND "${TGT_SCRIPT}" "\n")
FILE(APPEND "${TGT_SCRIPT}" "echo Bad current dir for that ; please run from the root folder of a CMake-enabled SD source tree.\n")
FILE(APPEND "${TGT_SCRIPT}" "\n")
FILE(APPEND "${TGT_SCRIPT}" ":END\n")
ELSE(WIN32)
SET(TGT_SCRIPT "${SOURCE_DIR}/clobber.sh")
FILE(WRITE "${TGT_SCRIPT}" "#!/bin/sh\n")
FILE(APPEND "${TGT_SCRIPT}" "# CMake-generated script for in-source build tree total cleanup\n")
FILE(APPEND "${TGT_SCRIPT}" "# (remove any build-system-generated file (+ .bak, *~, ... etc), \n")
FILE(APPEND "${TGT_SCRIPT}" "# in case you want to get back to something like\n")
FILE(APPEND "${TGT_SCRIPT}" "# right after a 'svn checkout' command).\n")
FILE(APPEND "${TGT_SCRIPT}" "\n")
FILE(APPEND "${TGT_SCRIPT}" "# Check if we are on top of a CMake-enabled SD source tree\n")
FILE(APPEND "${TGT_SCRIPT}" "if [[ -f CMakeLists.txt && -f credits.xml && -d cmake && -d data && -d src ]] ; then\n")
FILE(APPEND "${TGT_SCRIPT}" "\n")
FILE(APPEND "${TGT_SCRIPT}" " echo \"Cleaning up in-source build tree ...\"\n")
FILE(APPEND "${TGT_SCRIPT}" " \n")
FILE(APPEND "${TGT_SCRIPT}" " # CMake generated files and dirs\n")
FILE(APPEND "${TGT_SCRIPT}" " rm -f CMakeCache.txt config.h doxygen_config\n")
FILE(APPEND "${TGT_SCRIPT}" " rm -f CPackConfig.cmake CPackSourceConfig.cmake\n")
FILE(APPEND "${TGT_SCRIPT}" " rm -f uninstall.cmake\n")
FILE(APPEND "${TGT_SCRIPT}" " rm -f xmlversion_loc.txt install_manifest.txt version.h.txt\n")
FILE(APPEND "${TGT_SCRIPT}" " rm -fr _CPack_Packages\n")
FILE(APPEND "${TGT_SCRIPT}" " find . -type d -name \"CMakeFiles\" -exec rm -fr {} \\;\n")
FILE(APPEND "${TGT_SCRIPT}" " find . -type f -name \"cmake_install.cmake\" -delete\n")
FILE(APPEND "${TGT_SCRIPT}" " find . -type f -name \"Makefile\" -delete\n")
FILE(APPEND "${TGT_SCRIPT}" "\n")
FILE(APPEND "${TGT_SCRIPT}" " # Other useless files\n")
FILE(APPEND "${TGT_SCRIPT}" " find . -type f -name \"*.rej\" -delete\n")
FILE(APPEND "${TGT_SCRIPT}" " find . -type f -name \"*.orig\" -delete\n")
FILE(APPEND "${TGT_SCRIPT}" " find . -type f -name \"*.flc\" -delete\n")
FILE(APPEND "${TGT_SCRIPT}" " find . -type f -name \"*.bak\" -delete\n")
FILE(APPEND "${TGT_SCRIPT}" " find . -type f -name \"*~\" -delete\n")
FILE(APPEND "${TGT_SCRIPT}" " find . -type f -name \"*.~*\" -delete\n")
FILE(APPEND "${TGT_SCRIPT}" " \n")
FILE(APPEND "${TGT_SCRIPT}" " echo \"Done.\"\n")
FILE(APPEND "${TGT_SCRIPT}" " \n")
FILE(APPEND "${TGT_SCRIPT}" "else\n")
FILE(APPEND "${TGT_SCRIPT}" " echo \"Bad current dir for that ; please run from the root folder of a CMake-enabled SD source tree.\"\n")
FILE(APPEND "${TGT_SCRIPT}" "fi\n")
EXECUTE_PROCESS(COMMAND chmod ugo+x ${TGT_SCRIPT})
ENDIF(WIN32)
ENDIF(IN_SOURCETREE)
ENDMACRO(SD_GENERATE_CLOBBER_SCRIPT)
ADD_SD_DEFINITIONS()