|
| 1 | +# Check if this loader is enabled |
| 2 | +if(NOT OPTION_BUILD_LOADERS OR NOT OPTION_BUILD_LOADERS_RS OR NOT OPTION_BUILD_SCRIPTS OR NOT OPTION_BUILD_SCRIPTS_RS) |
| 3 | + return() |
| 4 | +endif() |
| 5 | + |
| 6 | +# |
| 7 | +# Executable name and options |
| 8 | +# |
| 9 | + |
| 10 | +# Target name |
| 11 | +set(target metacall-rust-test) |
| 12 | +message(STATUS "Test ${target}") |
| 13 | + |
| 14 | +# |
| 15 | +# Compiler warnings |
| 16 | +# |
| 17 | + |
| 18 | +include(Warnings) |
| 19 | + |
| 20 | +# |
| 21 | +# Compiler security |
| 22 | +# |
| 23 | + |
| 24 | +include(SecurityFlags) |
| 25 | + |
| 26 | +# |
| 27 | +# Sources |
| 28 | +# |
| 29 | + |
| 30 | +set(include_path "${CMAKE_CURRENT_SOURCE_DIR}/include/${target}") |
| 31 | +set(source_path "${CMAKE_CURRENT_SOURCE_DIR}/source") |
| 32 | + |
| 33 | +set(sources |
| 34 | + ${source_path}/main.cpp |
| 35 | + ${source_path}/metacall_rust_test.cpp |
| 36 | +) |
| 37 | + |
| 38 | +# Group source files |
| 39 | +set(header_group "Header Files (API)") |
| 40 | +set(source_group "Source Files") |
| 41 | +source_group_by_path(${include_path} "\\\\.h$|\\\\.hpp$" |
| 42 | + ${header_group} ${headers}) |
| 43 | +source_group_by_path(${source_path} "\\\\.cpp$|\\\\.c$|\\\\.h$|\\\\.hpp$" |
| 44 | + ${source_group} ${sources}) |
| 45 | + |
| 46 | +# |
| 47 | +# Create executable |
| 48 | +# |
| 49 | + |
| 50 | +# Build executable |
| 51 | +add_executable(${target} |
| 52 | + ${sources} |
| 53 | +) |
| 54 | + |
| 55 | +# Create namespaced alias |
| 56 | +add_executable(${META_PROJECT_NAME}::${target} ALIAS ${target}) |
| 57 | + |
| 58 | +# |
| 59 | +# Project options |
| 60 | +# |
| 61 | + |
| 62 | +set_target_properties(${target} |
| 63 | + PROPERTIES |
| 64 | + ${DEFAULT_PROJECT_OPTIONS} |
| 65 | + FOLDER "${IDE_FOLDER}" |
| 66 | +) |
| 67 | + |
| 68 | +# |
| 69 | +# Include directories |
| 70 | +# |
| 71 | + |
| 72 | +target_include_directories(${target} |
| 73 | + PRIVATE |
| 74 | + ${DEFAULT_INCLUDE_DIRECTORIES} |
| 75 | + ${PROJECT_BINARY_DIR}/source/include |
| 76 | +) |
| 77 | + |
| 78 | +# |
| 79 | +# Libraries |
| 80 | +# |
| 81 | + |
| 82 | +target_link_libraries(${target} |
| 83 | + PRIVATE |
| 84 | + ${DEFAULT_LIBRARIES} |
| 85 | + |
| 86 | + GTest |
| 87 | + |
| 88 | + ${META_PROJECT_NAME}::metacall |
| 89 | +) |
| 90 | + |
| 91 | +# |
| 92 | +# Compile definitions |
| 93 | +# |
| 94 | + |
| 95 | +target_compile_definitions(${target} |
| 96 | + PRIVATE |
| 97 | + ${DEFAULT_COMPILE_DEFINITIONS} |
| 98 | +) |
| 99 | + |
| 100 | +# |
| 101 | +# Compile options |
| 102 | +# |
| 103 | + |
| 104 | +target_compile_options(${target} |
| 105 | + PRIVATE |
| 106 | + ${DEFAULT_COMPILE_OPTIONS} |
| 107 | +) |
| 108 | + |
| 109 | +# |
| 110 | +# Linker options |
| 111 | +# |
| 112 | + |
| 113 | +target_link_libraries(${target} |
| 114 | + PRIVATE |
| 115 | + ${DEFAULT_LINKER_OPTIONS} |
| 116 | +) |
| 117 | + |
| 118 | +# |
| 119 | +# Define test |
| 120 | +# |
| 121 | + |
| 122 | +add_test(NAME ${target} |
| 123 | + COMMAND $<TARGET_FILE:${target}> |
| 124 | +) |
| 125 | + |
| 126 | +# |
| 127 | +# Define dependencies |
| 128 | +# |
| 129 | + |
| 130 | +add_dependencies(${target} |
| 131 | + rs_loader |
| 132 | +) |
| 133 | + |
| 134 | +# |
| 135 | +# Define test properties |
| 136 | +# |
| 137 | + |
| 138 | +set_property(TEST ${target} |
| 139 | + PROPERTY LABELS ${target} |
| 140 | +) |
| 141 | + |
| 142 | +include(TestEnvironmentVariables) |
| 143 | + |
| 144 | +test_environment_variables(${target} |
| 145 | + "" |
| 146 | + ${TESTS_ENVIRONMENT_VARIABLES} |
| 147 | +) |
0 commit comments