Back to home page

EIC code displayed by LXR

 
 

    


Warning, /estarlight/cmake_modules/CommonMacros.cmake is written in an unsupported language. File is not indexed.

0001 ###########################################################################
0002 #
0003 #    Copyright 2010
0004 #
0005 #    This file is part of Starlight.
0006 #
0007 #    Starlight is free software: you can redistribute it and/or modify
0008 #    it under the terms of the GNU General Public License as published by
0009 #    the Free Software Foundation, either version 3 of the License, or
0010 #    (at your option) any later version.
0011 #         
0012 #    Starlight is distributed in the hope that it will be useful,
0013 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
0014 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0015 #    GNU General Public License for more details.
0016 #         
0017 #    You should have received a copy of the GNU General Public License
0018 #    along with Starlight. If not, see <http://www.gnu.org/licenses/>.
0019 #
0020 ###########################################################################
0021 #
0022 # File and Version Information:
0023 # $Rev:: 27                          $: revision of last commit
0024 # $Author:: bgrube                   $: author of last commit
0025 # $Date:: 2010-11-29 12:00:04 +0000 #$: date of last commit
0026 #
0027 # Description:
0028 #      collection of useful cmake macros
0029 #
0030 #
0031 ###########################################################################
0032 
0033 
0034 # takes list of file names and returns file name list with new extension
0035 # example:
0036 #   switch_file_extension("${CC_LIST}" ".cc" ".h" H_LIST)
0037 function(switch_file_extension IN_FILE_LIST OLD_EXT NEW_EXT OUT_FILE_LIST)
0038   set(NEW_FILE_LIST)
0039   foreach(_OLD_FILE ${IN_FILE_LIST})
0040     string(REGEX REPLACE "^(.*)${OLD_EXT}$" "\\1${NEW_EXT}" _NEW_FILE ${_OLD_FILE})
0041     set(NEW_FILE_LIST ${NEW_FILE_LIST} ${_NEW_FILE})
0042   endforeach()
0043   set(${OUT_FILE_LIST} ${NEW_FILE_LIST})
0044 endfunction(switch_file_extension)
0045 
0046 
0047 # adds standard shared library
0048 # additional libraries that should be linked to can be given as optional arguments
0049 function(make_shared_library LIB_NAME SOURCES)
0050   add_library(${LIB_NAME} SHARED ${SOURCES})
0051   # proccess link libraries in additional arguments
0052   foreach(_LIB ${ARGN})
0053     target_link_libraries(${LIB_NAME} ${_LIB})
0054   endforeach()
0055 endfunction(make_shared_library)
0056 
0057 
0058 # adds standard executable
0059 # additional libraries that should be linked to can be given as optional arguments
0060 function(make_executable EXE_NAME SOURCES)
0061   add_executable(${EXE_NAME} ${SOURCES})
0062   # proccess link libraries in additional arguments
0063   foreach(_LIB ${ARGN})
0064     target_link_libraries(${EXE_NAME} ${_LIB})
0065   endforeach()
0066 endfunction(make_executable)
0067 
0068 
0069 macro(enforce_out_of_source_build)
0070   if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
0071     message(FATAL_ERROR "Building this project in the source directory is not allowed. Please remove CMakeCache.txt, create a build directory, and run cmake there, for example:
0072 rm CMakeCache.txt
0073 mkdir build && cd build
0074 cmake ..")
0075   endif()
0076 endmacro(enforce_out_of_source_build)