summaryrefslogtreecommitdiffstats
path: root/Modules/CheckOBJCSourceRuns.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/CheckOBJCSourceRuns.cmake')
-rw-r--r--Modules/CheckOBJCSourceRuns.cmake77
1 files changed, 2 insertions, 75 deletions
diff --git a/Modules/CheckOBJCSourceRuns.cmake b/Modules/CheckOBJCSourceRuns.cmake
index 9d4fb1b..dadab21 100644
--- a/Modules/CheckOBJCSourceRuns.cmake
+++ b/Modules/CheckOBJCSourceRuns.cmake
@@ -67,81 +67,8 @@ subsequently be run.
#]=======================================================================]
include_guard(GLOBAL)
+include(CheckSourceRuns)
macro(CHECK_OBJC_SOURCE_RUNS SOURCE VAR)
- if(NOT DEFINED "${VAR}")
- set(MACRO_CHECK_FUNCTION_DEFINITIONS
- "-D${VAR} ${CMAKE_REQUIRED_FLAGS}")
- if(CMAKE_REQUIRED_LINK_OPTIONS)
- set(CHECK_OBJC_SOURCE_COMPILES_ADD_LINK_OPTIONS
- LINK_OPTIONS ${CMAKE_REQUIRED_LINK_OPTIONS})
- else()
- set(CHECK_OBJC_SOURCE_COMPILES_ADD_LINK_OPTIONS)
- endif()
- if(CMAKE_REQUIRED_LIBRARIES)
- set(CHECK_OBJC_SOURCE_COMPILES_ADD_LIBRARIES
- LINK_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
- else()
- set(CHECK_OBJC_SOURCE_COMPILES_ADD_LIBRARIES)
- endif()
- if(CMAKE_REQUIRED_INCLUDES)
- set(CHECK_OBJC_SOURCE_COMPILES_ADD_INCLUDES
- "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}")
- else()
- set(CHECK_OBJC_SOURCE_COMPILES_ADD_INCLUDES)
- endif()
- file(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.m"
- "${SOURCE}\n")
-
- if(NOT CMAKE_REQUIRED_QUIET)
- message(CHECK_START "Performing Test ${VAR}")
- endif()
- try_run(${VAR}_EXITCODE ${VAR}_COMPILED
- ${CMAKE_BINARY_DIR}
- ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.m
- COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
- ${CHECK_OBJC_SOURCE_COMPILES_ADD_LINK_OPTIONS}
- ${CHECK_OBJC_SOURCE_COMPILES_ADD_LIBRARIES}
- CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
- -DCMAKE_SKIP_RPATH:BOOL=${CMAKE_SKIP_RPATH}
- "${CHECK_OBJC_SOURCE_COMPILES_ADD_INCLUDES}"
- COMPILE_OUTPUT_VARIABLE OUTPUT
- RUN_OUTPUT_VARIABLE RUN_OUTPUT)
- # if it did not compile make the return value fail code of 1
- if(NOT ${VAR}_COMPILED)
- set(${VAR}_EXITCODE 1)
- endif()
- # if the return value was 0 then it worked
- if("${${VAR}_EXITCODE}" EQUAL 0)
- set(${VAR} 1 CACHE INTERNAL "Test ${VAR}")
- if(NOT CMAKE_REQUIRED_QUIET)
- message(CHECK_PASS "Success")
- endif()
- file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
- "Performing Objective-C SOURCE FILE Test ${VAR} succeeded with the following compile output:\n"
- "${OUTPUT}\n"
- "...and run output:\n"
- "${RUN_OUTPUT}\n"
- "Return value: ${${VAR}}\n"
- "Source file was:\n${SOURCE}\n")
- else()
- if(CMAKE_CROSSCOMPILING AND "${${VAR}_EXITCODE}" MATCHES "FAILED_TO_RUN")
- set(${VAR} "${${VAR}_EXITCODE}")
- else()
- set(${VAR} "" CACHE INTERNAL "Test ${VAR}")
- endif()
-
- if(NOT CMAKE_REQUIRED_QUIET)
- message(CHECK_FAIL "Failed")
- endif()
- file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
- "Performing Objective-C SOURCE FILE Test ${VAR} failed with the following compile output:\n"
- "${OUTPUT}\n"
- "...and run output:\n"
- "${RUN_OUTPUT}\n"
- "Return value: ${${VAR}_EXITCODE}\n"
- "Source file was:\n${SOURCE}\n")
-
- endif()
- endif()
+ check_source_runs(OBJC "${SOURCE}" ${VAR} ${ARGN})
endmacro()