https://github.com/Kitware/CMake
Raw File
Tip revision: 0f88f57389fd636d76b7f726ac94933476d6c195 authored by Brad King on 02 July 2024, 14:40:35 UTC
CMake 3.30.0
Tip revision: 0f88f57
CMakeLists.txt
cmake_minimum_required(VERSION 3.1)
project(SourceFileProperty C)

if (EXISTS icasetest.c)
  # If a file exists by this name, use it.
  set_source_files_properties(icasetest.c
    PROPERTIES
      COMPILE_DEFINITIONS NEEDED_TO_WORK)
else ()
  # Work on case-sensitive file systems as well.
  set_source_files_properties(main.c
    PROPERTIES
      COMPILE_DEFINITIONS NO_NEED_TO_CALL)
endif ()

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 ()
back to top