cmake/Tests/SourceFileProperty/CMakeLists.txt

28 lines
810 B
CMake
Raw Normal View History

2020-02-01 23:06:01 +01:00
cmake_minimum_required(VERSION 3.1)
2015-04-27 22:25:09 +02:00
project(SourceFileProperty C)
if (EXISTS icasetest.c)
# If a file exists by this name, use it.
set_source_files_properties(icasetest.c
PROPERTIES
2020-02-01 23:06:01 +01:00
COMPILE_DEFINITIONS NEEDED_TO_WORK)
2015-04-27 22:25:09 +02:00
else ()
# Work on case-sensitive file systems as well.
set_source_files_properties(main.c
PROPERTIES
2020-02-01 23:06:01 +01:00
COMPILE_DEFINITIONS NO_NEED_TO_CALL)
2015-04-27 22:25:09 +02:00
endif ()
2020-02-01 23:06:01 +01:00
add_executable(SourceFileProperty main.c)
target_sources(SourceFileProperty PRIVATE ICaseTest.c)
get_source_file_property(LANG_MAIN main.c LANGUAGE)
if(NOT "${LANG_MAIN}" STREQUAL "C")
message(FATAL_ERROR "Bad language for file main.c")
endif()
get_property(LANG_TEST SOURCE ICaseTest.c PROPERTY LANGUAGE)
if (NOT "${LANG_TEST}" STREQUAL "C")
message(FATAL_ERROR "Bad language for file ICaseTest.c")
endif ()