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