third_party_libsnd/cmake/TestInline.cmake
Anonymous Maarten d7efb3bfc6 CMake: Allow parallel out-of-tree build
This allows parallel builds of different LibSndFile configurations

- results of configure_file and AutoGen are saved in CMAKE_BINARY_DIR
- the directory ${CMAKE_BINARY_DIR}/src is make a public include directory
- remove generated files in source tree prior to generation + fix install

Related: https://github.com/erikd/libsndfile/issues/71
2017-04-25 19:21:40 +10:00

55 lines
2.3 KiB
CMake

macro (TEST_INLINE)
if (NOT DEFINED INLINE_CODE)
message (STATUS "Checking for inline...")
set (INLINE_KEYWORD "inline")
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/cmake/TestInline.c.in ${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/TestInline.c)
try_compile (HAVE_INLINE "${CMAKE_CURRENT_BINARY_DIR}"
"${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/TestInline.c")
if (HAVE_INLINE)
message (STATUS "Checking for inline... supported")
else ()
message (STATUS "Checking for inline... not supported")
message (STATUS "Checking for __inline...")
set (INLINE_KEYWORD "__inline")
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/cmake/TestInline.c.in ${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/TestInline.c)
try_compile (HAVE___INLINE "${CMAKE_CURRENT_BINARY_DIR}"
"${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/TestInline.c")
if (HAVE___INLINE)
message (STATUS "Checking for __inline... supported")
else ()
message (STATUS "Checking for __inline... not supported")
message (STATUS "Checking for __inline__...")
set (INLINE_KEYWORD "__inline__")
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/cmake/TestInline.c.in ${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/TestInline.c)
try_compile (HAVE___INLINE "${CMAKE_CURRENT_BINARY_DIR}"
"${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/TestInline.c")
if (HAVE___INLINE)
message (STATUS "Checking for __inline__... supported")
message (STATUS "Checking for __inline__...")
set (INLINE_KEYWORD "__inline__")
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/cmake/TestInline.c.in ${CMAKE_CURRENT_SOURCE_DIR}/cmake/TestInline.c)
try_compile (HAVE___INLINE__ "${CMAKE_CURRENT_BINARY_DIR}"
"${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/TestInline.c")
else ()
message (STATUS "Checking for __inline__... not supported")
set (INLINE_KEYWORD "")
endif ()
endif ()
endif ()
if (HAVE_INLINE)
set (INLINE_CODE "/* #undef inline */" CACHE INTERNAL "")
elseif (HAVE___INLINE)
set (INLINE_CODE "#define inline __inline" CACHE INTERNAL "")
elseif (HAVE___INLINE__)
set (INLINE_CODE "#define inline __inline__" CACHE INTERNAL "")
else ()
set (INLINE_CODE "#define inline " CACHE INTERNAL "")
endif ()
endif ()
endmacro (TEST_INLINE)