diff options
Diffstat (limited to 'Tests/GhsMulti/GhsMultiCompilerOptions')
-rw-r--r-- | Tests/GhsMulti/GhsMultiCompilerOptions/CMakeLists.txt | 92 | ||||
-rw-r--r-- | Tests/GhsMulti/GhsMultiCompilerOptions/CMakeLists.txt.in | 32 | ||||
-rw-r--r-- | Tests/GhsMulti/GhsMultiCompilerOptions/test.c | 4 |
3 files changed, 128 insertions, 0 deletions
diff --git a/Tests/GhsMulti/GhsMultiCompilerOptions/CMakeLists.txt b/Tests/GhsMulti/GhsMultiCompilerOptions/CMakeLists.txt new file mode 100644 index 0000000..4a3f5c2 --- /dev/null +++ b/Tests/GhsMulti/GhsMultiCompilerOptions/CMakeLists.txt @@ -0,0 +1,92 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +cmake_minimum_required(VERSION 3.12 FATAL_ERROR) + +project(test C) + +message("Copy project") +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt.in + ${CMAKE_CURRENT_BINARY_DIR}/src/CMakeLists.txt COPYONLY) + +file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/test.c + DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/src +) + +message("Building project") +set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) +try_compile(RESULT + ${CMAKE_CURRENT_BINARY_DIR}/build + ${CMAKE_CURRENT_BINARY_DIR}/src + test + CMAKE_FLAGS + -DRUN_TEST=${RUN_TEST} + -DCMAKE_BUILD_TYPE=${RUN_TEST_BUILD_TYPE} + OUTPUT_VARIABLE OUTPUT) + +message("Output from build:\n${OUTPUT}") +if (RUN_TEST STREQUAL "RELEASE_FLAGS") + find_file (fileName test_none.gpj + ${CMAKE_CURRENT_BINARY_DIR}/build + ${CMAKE_CURRENT_BINARY_DIR}/build/test_none + ) + message("Parsing project file: ${fileName}") + file(STRINGS ${fileName} fileText) + set(opt "-unexpected_release_option") + string(FIND "${fileText}" "${opt}" opt_found) + if ( NOT opt_found EQUAL -1 ) + message(SEND_ERROR "Release option found: ${opt}") + endif() +else() + unset(fileName CACHE) + find_file (fileName K1.gpj + ${CMAKE_CURRENT_BINARY_DIR}/build + ${CMAKE_CURRENT_BINARY_DIR}/build/K1 + ) + message("Parsing project file: ${fileName}") + file(STRINGS ${fileName} fileText) + set(opt "-required-debug-option") + string(FIND "${fileText}" "${opt}" opt_found) + if ( opt_found EQUAL -1 ) + message(SEND_ERROR "Missing debug option: ${opt}") + endif() + + unset(fileName CACHE) + find_file (fileName K2.gpj + ${CMAKE_CURRENT_BINARY_DIR}/build + ${CMAKE_CURRENT_BINARY_DIR}/build/K2 + ) + message("Parsing project file: ${fileName}") + file(STRINGS ${fileName} fileText) + set(opt "-required-debug-option") + string(FIND "${fileText}" "${opt}" opt_found) + if ( opt_found EQUAL -1 ) + message(SEND_ERROR "Missing debug option: ${opt}") + endif() + + unset(fileName CACHE) + find_file (fileName K3.gpj + ${CMAKE_CURRENT_BINARY_DIR}/build + ${CMAKE_CURRENT_BINARY_DIR}/build/K3 + ) + message("Parsing project file: ${fileName}") + file(STRINGS ${fileName} fileText) + set(opt "-required-debug-option") + string(FIND "${fileText}" "${opt}" opt_found) + if ( opt_found EQUAL -1 ) + message(SEND_ERROR "Missing debug option: ${opt}") + endif() + + unset(fileName CACHE) + find_file (fileName K4.gpj + ${CMAKE_CURRENT_BINARY_DIR}/build + ${CMAKE_CURRENT_BINARY_DIR}/build/K4 + ) + message("Parsing project file: ${fileName}") + file(STRINGS ${fileName} fileText) + set(opt "-required-debug-option") + string(FIND "${fileText}" "${opt}" opt_found) + if ( opt_found EQUAL -1 ) + message(SEND_ERROR "Missing debug option: ${opt}") + endif() +endif() diff --git a/Tests/GhsMulti/GhsMultiCompilerOptions/CMakeLists.txt.in b/Tests/GhsMulti/GhsMultiCompilerOptions/CMakeLists.txt.in new file mode 100644 index 0000000..fc24d90 --- /dev/null +++ b/Tests/GhsMulti/GhsMultiCompilerOptions/CMakeLists.txt.in @@ -0,0 +1,32 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +cmake_minimum_required(VERSION 3.12 FATAL_ERROR) + +project(test C) + +if(CMAKE_C_COMPILER_ID STREQUAL "GHS") + add_link_options("-non_shared") +endif() + +if(RUN_TEST STREQUAL "RELEASE_FLAGS") + #RELEASE flags used when CMAKE_BUILD_TYPE is undefined + string(APPEND CMAKE_C_FLAGS_RELEASE " -unexpected_release_option") + add_executable(test_none test.c) +endif() + +if(RUN_TEST STREQUAL "KERNEL_FLAGS") + #DEBUG flag missing when -kernel is added as a compile option + string(APPEND CMAKE_C_FLAGS_DEBUG " -required-debug-option") + + add_executable(K1 test.c) + + add_executable(K2 test.c) + target_compile_options(K2 PRIVATE -kernel) + + add_executable(K3 test.c) + target_compile_options(K3 PRIVATE -kernel=fast) + + add_executable(K4 test.c) + target_link_options(K4 PRIVATE -kernel) +endif() diff --git a/Tests/GhsMulti/GhsMultiCompilerOptions/test.c b/Tests/GhsMulti/GhsMultiCompilerOptions/test.c new file mode 100644 index 0000000..95f2e8e --- /dev/null +++ b/Tests/GhsMulti/GhsMultiCompilerOptions/test.c @@ -0,0 +1,4 @@ +int main(void) +{ + return -1; +} |