Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
usFunctionCheckResourceLinking.cmake
Go to the documentation of this file.
2  if(NOT DEFINED US_RESOURCE_LINKING_AVAILABLE)
3  set(_suffix )
4  # Check linking capability
5  set(_linking_available 0)
6  if(APPLE)
7  set(_result )
8  usFunctionCheckCompilerFlags("-Wl,-sectcreate,__TEXT,us_resources,CMakeLists.txt" _result)
9  if(_result)
10  set(_linking_available 1)
11  endif()
12  set(_suffix .o)
13  elseif(WIN32 AND CMAKE_RC_COMPILER)
14  set(_linking_available 1)
15  set(_suffix .rc)
16  elseif(UNIX)
17  execute_process(
18  COMMAND ${CMAKE_LINKER} -r -b binary -o "${CMAKE_CURRENT_BINARY_DIR}/us_resource_link.o" "${CMAKE_COMMAND}"
19  RESULT_VARIABLE _result
20  )
21  if(_result EQUAL 0)
22  set(_linking_available 1)
23  endif()
24  set(_suffix .o)
25  endif()
26 
27  set(US_RESOURCE_SOURCE_SUFFIX_LINK ${_suffix} CACHE INTERNAL "CppMicroServices resource source suffix (link)" FORCE)
28  set(US_RESOURCE_SOURCE_SUFFIX_APPEND ".cpp" CACHE INTERNAL "CppMicroServices resource source suffix (append)" FORCE)
29 
30  set(_success "no")
31  set(_default_mode "APPEND")
32  if(_linking_available)
33  set(_success "yes")
34  if(APPLE)
35  set(_default_mode "LINK")
36  endif()
37  endif()
38 
39  message("Checking for CppMicroServices resource linking capability...${_success}")
40 
41  set(US_RESOURCE_LINKING_AVAILABLE ${_linking_available} CACHE INTERNAL "CppMicroServices resource linking" FORCE)
42  set(US_DEFAULT_RESOURCE_MODE ${_default_mode} CACHE INTERNAL "CppMicroServices default resource mode" FORCE)
43  if(_default_mode STREQUAL "LINK")
44  set(US_RESOURCE_SOURCE_SUFFIX ${US_RESOURCE_SOURCE_SUFFIX_LINK} CACHE INTERNAL "CppMicroServices resource source suffix" FORCE)
45  else()
46  set(US_RESOURCE_SOURCE_SUFFIX ${US_RESOURCE_SOURCE_SUFFIX_APPEND} CACHE INTERNAL "CppMicroServices resource source suffix" FORCE)
47  endif()
48  endif()
49 endfunction()
usFunctionCheckCompilerFlags(FLAG_TO_TEST, RESULT_VAR)
usFunctionCheckResourceLinking()
const std::string LINK