1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
# Author: Omar Shrit
#[=======================================================================[.rst:
TestForSTB
----------
Test to verify if the available version of STB contains a working static
implementation that can be used from multiple translation units.
::
CMAKE_HAS_WORKING_STATIC_STB - defined by the results
#]=======================================================================]
if(NOT DEFINED CMAKE_HAS_WORKING_STATIC_STB)
message(STATUS "Check that STB static implementation mode links correctly...")
set(TEST_CXX_DEFS "")
if (NOT STB_INCLUDE_NEEDS_STB_SUFFIX)
set(TEST_CXX_DEFS "-DMLPACK_HAS_NO_STB_DIR")
endif ()
try_compile(CMAKE_HAS_WORKING_STATIC_STB
${CMAKE_BINARY_DIR}/CMakeFiles/CMakeTmp/
SOURCES
${CMAKE_SOURCE_DIR}/CMake/stb/main.cpp
${CMAKE_SOURCE_DIR}/CMake/stb/a.cpp
${CMAKE_SOURCE_DIR}/CMake/stb/b.cpp
CMAKE_FLAGS "-DINCLUDE_DIRECTORIES=${STB_IMAGE_INCLUDE_DIR}"
COMPILE_DEFINITIONS "${TEST_CXX_DEFS}"
OUTPUT_VARIABLE out)
if (CMAKE_HAS_WORKING_STATIC_STB)
message(STATUS "Check that STB static implementation mode links "
"correctly... success")
message(STATUS
"Determining if STB's static implementation can link correctly passed "
"with the following output:\n${out}\n\n")
set(CMAKE_HAS_WORKING_STATIC_STB 1 CACHE INTERNAL
"Does STB static implementation mode link correctly")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Determining if STB's static implementation can link correctly passed "
"with the following output:\n${out}\n\n")
else ()
message(STATUS "Check that STB static implementation mode links "
"correctly... fail")
message(STATUS
"Determining if STB's static implementation can link correctly failed "
"with the following output:\n${out}\n\n")
set(CMAKE_HAS_WORKING_STATIC_STB 0 CACHE INTERNAL
"Does STB static implementation mode link correctly")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Determining if STB's static implementation can link correctly failed "
"with the following output:\n${out}\n\n")
endif ()
endif()
|