| 1 |
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying |
| 2 |
# file LICENSE.rst or https://cmake.org/licensing for details. |
| 3 |
|
| 4 |
cmake_minimum_required(VERSION 3.12 FATAL_ERROR) |
| 5 |
|
| 6 |
project(test C) |
| 7 |
|
| 8 |
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) |
| 9 |
try_compile(RESULT |
| 10 |
${CMAKE_CURRENT_BINARY_DIR}/build |
| 11 |
${CMAKE_CURRENT_SOURCE_DIR}/test.c |
| 12 |
OUTPUT_VARIABLE OUTPUT |
| 13 |
COPY_FILE "${CMAKE_CURRENT_BINARY_DIR}/test_library" |
| 14 |
) |
| 15 |
|
| 16 |
message(STATUS "Output from build:\n${OUTPUT}") |
| 17 |
|
| 18 |
if(NOT RESULT) |
| 19 |
message(SEND_ERROR "try_compile() failed") |
| 20 |
endif() |
| 21 |
|
| 22 |
if(EXISTS "${CMAKE_CURRENT_BINARY_DIR}/test_library") |
| 23 |
if (IS_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test_library") |
| 24 |
message(SEND_ERROR "library is folder !") |
| 25 |
else() |
| 26 |
message(STATUS "library seems okay") |
| 27 |
endif() |
| 28 |
else() |
| 29 |
message(SEND_ERROR "library is not found !") |
| 30 |
endif() |