Mercurial > audio-send
view cmake/CheckCCompilerFlag.cmake @ 0:f9476ff7637e
initial forking of open-al to create multiple listeners
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Tue, 25 Oct 2011 13:02:31 -0700 |
parents | |
children |
line wrap: on
line source
1 # - Check if the C source code provided in the SOURCE argument compiles.2 # CHECK_C_SOURCE_COMPILES(SOURCE VAR)3 #4 # FLAG - compiler flag to check5 # VAR - variable to store whether the source code compiled6 #7 # The following variables may be set before calling this macro to8 # modify the way the check is run:9 #10 # CMAKE_REQUIRED_FLAGS = string of compile command line flags11 # CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)12 # CMAKE_REQUIRED_INCLUDES = list of include directories13 # CMAKE_REQUIRED_LIBRARIES = list of libraries to link15 MACRO(CHECK_C_COMPILER_FLAG FLAG VAR)16 IF("${VAR}" MATCHES "^${VAR}$")17 SET(MACRO_CHECK_FUNCTION_DEFINITIONS18 "${FLAG} ${CMAKE_REQUIRED_FLAGS}")19 IF(CMAKE_REQUIRED_LIBRARIES)20 SET(CHECK_C_COMPILER_FLAG_ADD_LIBRARIES21 "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}")22 ELSE(CMAKE_REQUIRED_LIBRARIES)23 SET(CHECK_C_COMPILER_FLAG_ADD_LIBRARIES)24 ENDIF(CMAKE_REQUIRED_LIBRARIES)25 IF(CMAKE_REQUIRED_INCLUDES)26 SET(CHECK_C_COMPILER_FLAG_ADD_INCLUDES27 "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}")28 ELSE(CMAKE_REQUIRED_INCLUDES)29 SET(CHECK_C_COMPILER_FLAG_ADD_INCLUDES)30 ENDIF(CMAKE_REQUIRED_INCLUDES)31 FILE(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c"32 "int main() {return 0;}\n")34 MESSAGE(STATUS "Checking if C compiler supports ${FLAG}")35 TRY_COMPILE(${VAR}36 ${CMAKE_BINARY_DIR}37 ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c38 COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}39 CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}40 "${CHECK_C_COMPILER_FLAG_ADD_LIBRARIES}"41 "${CHECK_C_COMPILER_FLAG_ADD_INCLUDES}"42 OUTPUT_VARIABLE OUTPUT)43 IF(${VAR})44 SET(${VAR} 1 CACHE INTERNAL "Test ${VAR}")45 MESSAGE(STATUS "Checking if C compiler supports ${FLAG} - Success")46 FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log47 "Performing C SOURCE FILE Test ${VAR} succeded with the following output:\n"48 "${OUTPUT}\n"49 "Source file was:\n${SOURCE}\n")50 ELSE(${VAR})51 MESSAGE(STATUS "Checking if C compiler supports ${FLAG} - Failed")52 SET(${VAR} "" CACHE INTERNAL "Test ${VAR}")53 FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log54 "Performing C SOURCE FILE Test ${VAR} failed with the following output:\n"55 "${OUTPUT}\n"56 "Source file was:\n${SOURCE}\n")57 ENDIF(${VAR})58 ENDIF("${VAR}" MATCHES "^${VAR}$")59 ENDMACRO(CHECK_C_COMPILER_FLAG)