Files
CMake/Tests/RunCMake/SymlinkTrees/CMakeLists.txt
T
Brad King 1edf138506 Tests/RunCMake: Update cmake_minimum_required versions
For policy-specific tests, use the version before the policy was
introduced.  Otherwise, use 3.5 where possible.

Also, remove `cmake_minimum_required()` and `project()` calls from
individual cases where they are handled by `CMakeLists.txt`.
2023-02-11 06:24:22 -05:00

53 lines
1.5 KiB
CMake

cmake_minimum_required(VERSION 3.5)
project(${RunCMake_TEST} NONE)
message(STATUS "source: '${CMAKE_SOURCE_DIR}'")
message(STATUS "binary: '${CMAKE_BINARY_DIR}'")
get_filename_component(real_source "${CMAKE_SOURCE_DIR}" REALPATH)
get_filename_component(real_binary "${CMAKE_BINARY_DIR}" REALPATH)
message(STATUS "real source: '${real_source}'")
message(STATUS "real binary: '${real_binary}'")
if(RunCMake_TEST MATCHES "-exe")
enable_language(C)
file(WRITE "${CMAKE_SOURCE_DIR}/source.c" [[
#include <stdio.h>
#include "source.h"
#include "binary.h"
extern void print_binary_c(void);
extern void print_binary_c(void);
void print_source_c(void) {
printf("source.c: '%s'\n", __FILE__);
}
int main(void) {
print_source_c();
print_source_h();
print_binary_c();
print_binary_h();
return 0;
}
]])
file(WRITE "${CMAKE_BINARY_DIR}/binary.c" [[
#include <stdio.h>
void print_binary_c(void) {
printf("binary.c: '%s'\n", __FILE__);
}
]])
file(WRITE "${CMAKE_SOURCE_DIR}/include/source.h" [[
void print_source_h(void) {
printf("source.h: '%s'\n", __FILE__);
}
]])
file(WRITE "${CMAKE_BINARY_DIR}/include/binary.h" [[
void print_binary_h(void) {
printf("binary.h: '%s'\n", __FILE__);
}
]])
add_executable(exe source.c ${CMAKE_BINARY_DIR}/binary.c)
target_include_directories(exe PRIVATE
${CMAKE_SOURCE_DIR}/include
${CMAKE_BINARY_DIR}/include
)
add_custom_target(print ALL COMMAND exe)
endif()