diff options
author | Fred Baksik <frodak17@gmail.com> | 2019-01-09 04:52:12 (GMT) |
---|---|---|
committer | Fred Baksik <frodak17@gmail.com> | 2019-01-16 15:42:08 (GMT) |
commit | 21ab58d3f8782e80145f14eb6e72926c9d17afc6 (patch) | |
tree | 04b73d0d54cc854bedc8641aa5b7f73677362088 /Tests/GhsMulti | |
parent | 72e0c115b771fe9e3f4b5a5b6bd3bcdade77a7cb (diff) | |
download | CMake-21ab58d3f8782e80145f14eb6e72926c9d17afc6.zip CMake-21ab58d3f8782e80145f14eb6e72926c9d17afc6.tar.gz CMake-21ab58d3f8782e80145f14eb6e72926c9d17afc6.tar.bz2 |
GHS: Update test suite
-- Allow for testing default toolset settings
If CMake_TEST_GreenHillsMULTI_config is not defined then
just run the GHS tests using defaults.
-- Handle paths that contain spaces
-- Update test suite to use "-non_shared" linker option
Fixes linking issue if GHS is not shipped with shared libraries
-- Other minor cleanup
Diffstat (limited to 'Tests/GhsMulti')
18 files changed, 104 insertions, 66 deletions
diff --git a/Tests/GhsMulti/GhsMultiCompilerOptions/CMakeLists.txt.in b/Tests/GhsMulti/GhsMultiCompilerOptions/CMakeLists.txt.in index d425631..fc24d90 100644 --- a/Tests/GhsMulti/GhsMultiCompilerOptions/CMakeLists.txt.in +++ b/Tests/GhsMulti/GhsMultiCompilerOptions/CMakeLists.txt.in @@ -5,24 +5,28 @@ 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) + #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") + #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(K1 test.c) -add_executable(K2 test.c) -target_compile_options(K2 PRIVATE -kernel) + 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(K3 test.c) + target_compile_options(K3 PRIVATE -kernel=fast) -add_executable(K4 test.c) -target_link_options(K4 PRIVATE -kernel) + add_executable(K4 test.c) + target_link_options(K4 PRIVATE -kernel) endif() diff --git a/Tests/GhsMulti/GhsMultiDuplicateSourceFilenames/CMakeLists.txt b/Tests/GhsMulti/GhsMultiDuplicateSourceFilenames/CMakeLists.txt index 520e65f..a1f152f 100644 --- a/Tests/GhsMulti/GhsMultiDuplicateSourceFilenames/CMakeLists.txt +++ b/Tests/GhsMulti/GhsMultiDuplicateSourceFilenames/CMakeLists.txt @@ -12,6 +12,6 @@ add_library(libdemo add_executable(demo main.c) target_link_libraries(demo libdemo) -if(GHSMULTI) - target_compile_options(demo PUBLIC "-non_shared") +if(CMAKE_C_COMPILER_ID STREQUAL "GHS") + target_link_options(demo PRIVATE "-non_shared") endif() diff --git a/Tests/GhsMulti/GhsMultiExclude/CMakeLists.txt b/Tests/GhsMulti/GhsMultiExclude/CMakeLists.txt index 329cb3f..0448cf2 100644 --- a/Tests/GhsMulti/GhsMultiExclude/CMakeLists.txt +++ b/Tests/GhsMulti/GhsMultiExclude/CMakeLists.txt @@ -5,6 +5,10 @@ cmake_minimum_required(VERSION 3.12 FATAL_ERROR) project(test C) +if(CMAKE_C_COMPILER_ID STREQUAL "GHS") + add_link_options("-non_shared") +endif() + add_library(lib1 lib1.c) set_target_properties( lib1 PROPERTIES EXCLUDE_FROM_ALL yes ) diff --git a/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDD/CMakeLists.txt b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDD/CMakeLists.txt index 3d0642d..d4cbf04 100644 --- a/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDD/CMakeLists.txt +++ b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDD/CMakeLists.txt @@ -5,6 +5,8 @@ cmake_minimum_required(VERSION 3.12 FATAL_ERROR) project(test C) +add_link_options("-non_shared") + # create virtual AS add_executable(vas exe.c) target_link_libraries(vas lib) diff --git a/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityMonolith/CMakeLists.txt b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityMonolith/CMakeLists.txt index 741fece..c5db155 100644 --- a/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityMonolith/CMakeLists.txt +++ b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityMonolith/CMakeLists.txt @@ -3,6 +3,8 @@ cmake_minimum_required(VERSION 3.12 FATAL_ERROR) +add_link_options("-non_shared") + project(test C) # create virtual AS diff --git a/Tests/GhsMulti/GhsMultiLinkTest/CMakeLists.txt b/Tests/GhsMulti/GhsMultiLinkTest/CMakeLists.txt index dfb72ce..da80b51 100644 --- a/Tests/GhsMulti/GhsMultiLinkTest/CMakeLists.txt +++ b/Tests/GhsMulti/GhsMultiLinkTest/CMakeLists.txt @@ -37,7 +37,7 @@ if (RUN_TEST STREQUAL "NO_FLAGS") endif() else() unset(fileName CACHE) - find_file (fileName exe1.gpj + find_file(fileName exe1.gpj ${CMAKE_CURRENT_BINARY_DIR}/link_build ${CMAKE_CURRENT_BINARY_DIR}/link_build/exe1 ) @@ -50,12 +50,12 @@ else() -lcsl1 csl2 -clinkexe1 -clinkexe2 -special-lib2-public-link) - foreach( opt IN LISTS expected_flags ) + foreach(opt IN LISTS expected_flags) string(FIND "${fileText}" "${opt}" opt_found) if ( opt_found EQUAL -1 ) message(SEND_ERROR "Could not find: ${opt}") endif() - endforeach(opt) + endforeach() unset(fileName CACHE) find_file (fileName lib1.gpj @@ -67,12 +67,12 @@ else() set(expected_flags -clinkexeA1 -clinkexeA2 -static-lib-flags1 -static-lib-flags2) - foreach( opt IN LISTS expected_flags ) + foreach(opt IN LISTS expected_flags) string(FIND "${fileText}" "${opt}" opt_found) - if ( opt_found EQUAL -1 ) + if (opt_found EQUAL -1) message(SEND_ERROR "Could not find: ${opt}") endif() - endforeach(opt) + endforeach() unset(fileName CACHE) find_file (fileName lib2.gpj @@ -83,10 +83,10 @@ else() file(STRINGS ${fileName} fileText) set(expected_flags -clinkexeA1 -clinkexeA2) - foreach( opt IN LISTS expected_flags ) + foreach(opt IN LISTS expected_flags) string(FIND "${fileText}" "${opt}" opt_found) if ( opt_found EQUAL -1 ) message(SEND_ERROR "Could not find: ${opt}") endif() - endforeach(opt) + endforeach() endif() diff --git a/Tests/GhsMulti/GhsMultiLinkTest/CMakeLists.txt.in b/Tests/GhsMulti/GhsMultiLinkTest/CMakeLists.txt.in index 4cf86a2..58c2115 100644 --- a/Tests/GhsMulti/GhsMultiLinkTest/CMakeLists.txt.in +++ b/Tests/GhsMulti/GhsMultiLinkTest/CMakeLists.txt.in @@ -5,31 +5,39 @@ cmake_minimum_required(VERSION 3.12 FATAL_ERROR) project(test C) -if( RUN_TEST STREQUAL "CHECK_FLAGS" ) -add_link_options(-add-link-options1 -add-link-options2) -link_directories(link_directories_used1 link_directories_used2 "c:/absolute") -link_libraries(link_libraries_used1 link_libraries_used2 ) -set( CMAKE_C_STANDARD_LIBRARIES "${CMAKE_C_STANDARD_LIBRARIES} -lcsl1 csl2" ) -set( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -clinkexe1 -clinkexe2") +if(CMAKE_C_COMPILER_ID STREQUAL "GHS") + add_link_options("-non_shared") +endif() + +if(RUN_TEST STREQUAL "CHECK_FLAGS") + add_link_options(-add-link-options1 -add-link-options2) + link_directories(link_directories_used1 link_directories_used2 "c:/absolute") + link_libraries(link_libraries_used1 link_libraries_used2 ) + set( CMAKE_C_STANDARD_LIBRARIES "${CMAKE_C_STANDARD_LIBRARIES} -lcsl1 csl2" ) + set( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -clinkexe1 -clinkexe2") endif() add_executable(exe1 exe1.c) target_link_libraries(exe1 lib1) -if( RUN_TEST STREQUAL "CHECK_FLAGS" ) -set_property( TARGET exe1 APPEND_STRING PROPERTY LINK_FLAGS "--link-flag-prop1 --link-flag-prop2") -set_property( TARGET exe1 APPEND PROPERTY LINK_OPTIONS --link-opt-prop1 --link-opt-prop2) + +if(RUN_TEST STREQUAL "CHECK_FLAGS") + set_property(TARGET exe1 APPEND_STRING PROPERTY LINK_FLAGS "--link-flag-prop1 --link-flag-prop2") + set_property(TARGET exe1 APPEND PROPERTY LINK_OPTIONS --link-opt-prop1 --link-opt-prop2) endif() -if( RUN_TEST STREQUAL "CHECK_FLAGS" ) -set( CMAKE_STATIC_LINKER_FLAGS ${CMAKE_STATIC_LINKER_FLAGS} "-clinkexeA1 -clinkexeA2") +if(RUN_TEST STREQUAL "CHECK_FLAGS") + set(CMAKE_STATIC_LINKER_FLAGS ${CMAKE_STATIC_LINKER_FLAGS} "-clinkexeA1 -clinkexeA2") endif() + add_library(lib1 STATIC func2.c func3.c func4.c) target_link_libraries(lib1 lib2) -if( RUN_TEST STREQUAL "CHECK_FLAGS" ) -set_property( TARGET lib1 APPEND_STRING PROPERTY STATIC_LIBRARY_FLAGS "-static-lib-flags1 -static-lib-flags2") + +if(RUN_TEST STREQUAL "CHECK_FLAGS") + set_property(TARGET lib1 APPEND_STRING PROPERTY STATIC_LIBRARY_FLAGS "-static-lib-flags1 -static-lib-flags2") endif() add_library(lib2 STATIC func5.c func6.c func7.c) -if( RUN_TEST STREQUAL "CHECK_FLAGS" ) -target_link_options(lib2 PUBLIC -special-lib2-public-link) + +if(RUN_TEST STREQUAL "CHECK_FLAGS") + target_link_options(lib2 PUBLIC -special-lib2-public-link) endif() diff --git a/Tests/GhsMulti/GhsMultiLinkTestSub/sub_exe/CMakeLists.txt b/Tests/GhsMulti/GhsMultiLinkTestSub/sub_exe/CMakeLists.txt index 55f693d..f49e33d 100644 --- a/Tests/GhsMulti/GhsMultiLinkTestSub/sub_exe/CMakeLists.txt +++ b/Tests/GhsMulti/GhsMultiLinkTestSub/sub_exe/CMakeLists.txt @@ -7,3 +7,6 @@ project(test C) add_executable(exe1 exe1.c) target_link_libraries(exe1 lib1) +if(CMAKE_C_COMPILER_ID STREQUAL "GHS") + target_link_options(exe1 PRIVATE "-non_shared") +endif() diff --git a/Tests/GhsMulti/GhsMultiMultipleProjects/CMakeLists.txt b/Tests/GhsMulti/GhsMultiMultipleProjects/CMakeLists.txt index d01c4d2..9e077a9 100644 --- a/Tests/GhsMulti/GhsMultiMultipleProjects/CMakeLists.txt +++ b/Tests/GhsMulti/GhsMultiMultipleProjects/CMakeLists.txt @@ -5,6 +5,10 @@ cmake_minimum_required(VERSION 3.12 FATAL_ERROR) project(test C) +if(CMAKE_C_COMPILER_ID STREQUAL "GHS") + add_link_options("-non_shared") +endif() + add_library(lib1 lib1.c) add_executable(exe1 exe1.c) target_link_libraries(exe1 lib1) diff --git a/Tests/GhsMulti/GhsMultiMultipleProjects/verify.cmake b/Tests/GhsMulti/GhsMultiMultipleProjects/verify.cmake index e00cbb3..3855215 100644 --- a/Tests/GhsMulti/GhsMultiMultipleProjects/verify.cmake +++ b/Tests/GhsMulti/GhsMultiMultipleProjects/verify.cmake @@ -3,13 +3,13 @@ #test project was generated unset(fileName CACHE) -find_file (fileName lib3.gpj +find_file(fileName lib3.gpj ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/lib3 ${CMAKE_CURRENT_BINARY_DIR}/examples ) -if ( fileName ) +if (fileName) message("Found target lib3: ${fileName}") else() message(SEND_ERROR "Could not find target lib3: ${fileName}") @@ -23,7 +23,7 @@ find_file (fileName exe3.gpj ${CMAKE_CURRENT_BINARY_DIR}/examples ) -if ( fileName ) +if (fileName) message("Found target exe3: ${fileName}") else() message(SEND_ERROR "Could not find target exe3: ${fileName}") @@ -37,7 +37,7 @@ find_file (fileName lib3.a ${CMAKE_CURRENT_BINARY_DIR}/examples ) -if ( fileName ) +if (fileName) message(SEND_ERROR "Found target lib3: ${fileName}") else() message("Could not find target lib3: ${fileName}") @@ -51,7 +51,7 @@ find_file (fileName NAMES exe3.as exe3 ${CMAKE_CURRENT_BINARY_DIR}/examples ) -if ( fileName ) +if (fileName) message(SEND_ERROR "Found target exe3: ${fileName}") else() message("Could not find target exe3: ${fileName}") diff --git a/Tests/GhsMulti/GhsMultiObjectLibrary/CMakeLists.txt b/Tests/GhsMulti/GhsMultiObjectLibrary/CMakeLists.txt index 7fe91bc..a025814 100644 --- a/Tests/GhsMulti/GhsMultiObjectLibrary/CMakeLists.txt +++ b/Tests/GhsMulti/GhsMultiObjectLibrary/CMakeLists.txt @@ -8,3 +8,6 @@ project(test C) add_library(obj1 OBJECT testObj.c testObj.h sub/testObj.c testObj2.c) add_executable(exe1 exe.c $<TARGET_OBJECTS:obj1>) +if(CMAKE_C_COMPILER_ID STREQUAL "GHS") + target_link_options(exe1 PRIVATE "-non_shared") +endif() diff --git a/Tests/GhsMulti/GhsMultiPlatform/CMakeLists.txt b/Tests/GhsMulti/GhsMultiPlatform/CMakeLists.txt index 222aa17..b177887 100644 --- a/Tests/GhsMulti/GhsMultiPlatform/CMakeLists.txt +++ b/Tests/GhsMulti/GhsMultiPlatform/CMakeLists.txt @@ -5,9 +5,12 @@ cmake_minimum_required(VERSION 3.12 FATAL_ERROR) project(test) +message("PLATFORM_ID = ${PLATFORM_ID}") + message("CMAKE_C_COMPILER = ${CMAKE_C_COMPILER}") message("CMAKE_C_COMPILER_ID = ${CMAKE_C_COMPILER_ID}") message("CMAKE_C_COMPILER_VERSION = ${CMAKE_C_COMPILER_VERSION}") +message("CMAKE_C_COMPILER_VERSION_INTERNAL = ${CMAKE_C_COMPILER_VERSION_INTERNAL}") message("CMAKE_C_PLATFORM_ID = ${CMAKE_C_PLATFORM_ID}") message("CMAKE_C_COMPILER_ARCHITECTURE_ID = ${CMAKE_C_COMPILER_ARCHITECTURE_ID}") message("CMAKE_C_COMPILER_ABI = ${CMAKE_C_COMPILER_ABI}") @@ -16,6 +19,7 @@ message("CMAKE_C_STANDARD_COMPUTED_DEFAULT = ${CMAKE_C_STANDARD_COMPUTED_DEFAULT message("CMAKE_CXX_COMPILER = ${CMAKE_CXX_COMPILER}") message("CMAKE_CXX_COMPILER_ID = ${CMAKE_CXX_COMPILER_ID}") message("CMAKE_CXX_COMPILER_VERSION = ${CMAKE_CXX_COMPILER_VERSION}") +message("CMAKE_CXX_COMPILER_VERSION_INTERNAL = ${CMAKE_CXX_COMPILER_VERSION_INTERNAL}") message("CMAKE_CXX_PLATFORM_ID = ${CMAKE_CXX_PLATFORM_ID}") message("CMAKE_CXX_COMPILER_ARCHITECTURE_ID = ${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}") message("CMAKE_CXX_COMPILER_ABI = ${CMAKE_CXX_COMPILER_ABI}") diff --git a/Tests/GhsMulti/GhsMultiPlatform/file1.c b/Tests/GhsMulti/GhsMultiPlatform/file1.c index 6f7c837..4132aa4 100644 --- a/Tests/GhsMulti/GhsMultiPlatform/file1.c +++ b/Tests/GhsMulti/GhsMultiPlatform/file1.c @@ -1,6 +1,4 @@ -#include <stdio.h> - int main(void) { - printf("Testing...\n"); + return -42; } diff --git a/Tests/GhsMulti/GhsMultiRenameInstall/CMakeLists.txt b/Tests/GhsMulti/GhsMultiRenameInstall/CMakeLists.txt index f10b2f0..f5792b4 100644 --- a/Tests/GhsMulti/GhsMultiRenameInstall/CMakeLists.txt +++ b/Tests/GhsMulti/GhsMultiRenameInstall/CMakeLists.txt @@ -7,29 +7,33 @@ project(test C) set(targets_to_install "") -if( RUN_TEST STREQUAL "SINGLE_EXEC" ) -add_executable(exe1 exe.c) -set(targets_to_install ${targets_to_install} exe1) +if(CMAKE_C_COMPILER_ID STREQUAL "GHS") + add_link_options("-non_shared") endif() -if( RUN_TEST STREQUAL "SINGLE_EXEC_RENAMED" ) -set(name new_name) -add_executable(exe1 exe.c) -set_property(TARGET exe1 PROPERTY RUNTIME_OUTPUT_DIRECTORY ${name}_bin_$<CONFIG>) -set_property(TARGET exe1 PROPERTY OUTPUT_NAME ${name}_$<CONFIG>) -set_property(TARGET exe1 PROPERTY SUFFIX .bin) -set(targets_to_install ${targets_to_install} exe1) +if(RUN_TEST STREQUAL "SINGLE_EXEC") + add_executable(exe1 exe.c) + set(targets_to_install ${targets_to_install} exe1) endif() -if( RUN_TEST STREQUAL "EXEC_AND_LIB" ) -add_library(lib1 lib1.c) -set_property(TARGET lib1 PROPERTY ARCHIVE_OUTPUT_DIRECTORY forced-$<CONFIG>) -set_property(TARGET lib1 PROPERTY SUFFIX .LL) -set_property(TARGET lib1 PROPERTY OUTPUT_NAME lib1_$<CONFIG>) +if(RUN_TEST STREQUAL "SINGLE_EXEC_RENAMED") + set(name new_name) + add_executable(exe1 exe.c) + set_property(TARGET exe1 PROPERTY RUNTIME_OUTPUT_DIRECTORY ${name}_bin_$<CONFIG>) + set_property(TARGET exe1 PROPERTY OUTPUT_NAME ${name}_$<CONFIG>) + set_property(TARGET exe1 PROPERTY SUFFIX .bin) + set(targets_to_install ${targets_to_install} exe1) +endif() + +if(RUN_TEST STREQUAL "EXEC_AND_LIB") + add_library(lib1 lib1.c) + set_property(TARGET lib1 PROPERTY ARCHIVE_OUTPUT_DIRECTORY forced-$<CONFIG>) + set_property(TARGET lib1 PROPERTY SUFFIX .LL) + set_property(TARGET lib1 PROPERTY OUTPUT_NAME lib1_$<CONFIG>) -add_executable(exe1 exe1.c) -target_link_libraries(exe1 lib1) -set(targets_to_install ${targets_to_install} exe1 lib1) + add_executable(exe1 exe1.c) + target_link_libraries(exe1 lib1) + set(targets_to_install ${targets_to_install} exe1 lib1) endif() install(TARGETS ${targets_to_install} diff --git a/Tests/GhsMulti/GhsMultiSrcGroups/CMakeLists.txt b/Tests/GhsMulti/GhsMultiSrcGroups/CMakeLists.txt index a4f84ca..93a1afc 100644 --- a/Tests/GhsMulti/GhsMultiSrcGroups/CMakeLists.txt +++ b/Tests/GhsMulti/GhsMultiSrcGroups/CMakeLists.txt @@ -35,6 +35,9 @@ add_executable(groups if(TEST_PROP) set_target_properties(groups PROPERTIES GHS_NO_SOURCE_GROUP_FILE ON) endif() +if(CMAKE_C_COMPILER_ID MATCHES "GHS") + target_link_options(groups PRIVATE "-non_shared") +endif() source_group( gC FILES sub/testOBJ.h testOBJ.c testOBJ.h sub/testOBJ.c ) source_group( gA FILES test1.c test1.h) source_group( gB test[65].c ) diff --git a/Tests/GhsMulti/GhsMultiSrcGroups/cmake.rule b/Tests/GhsMulti/GhsMultiSrcGroups/cmake.rule index 8b13789..c6cac69 100644 --- a/Tests/GhsMulti/GhsMultiSrcGroups/cmake.rule +++ b/Tests/GhsMulti/GhsMultiSrcGroups/cmake.rule @@ -1 +1 @@ - +empty diff --git a/Tests/GhsMulti/GhsMultiSrcGroups/object.o b/Tests/GhsMulti/GhsMultiSrcGroups/object.o index 8b13789..c6cac69 100644 --- a/Tests/GhsMulti/GhsMultiSrcGroups/object.o +++ b/Tests/GhsMulti/GhsMultiSrcGroups/object.o @@ -1 +1 @@ - +empty diff --git a/Tests/GhsMulti/GhsMultiSrcGroups/resource.pdf b/Tests/GhsMulti/GhsMultiSrcGroups/resource.pdf index 8b13789..e69de29 100644 --- a/Tests/GhsMulti/GhsMultiSrcGroups/resource.pdf +++ b/Tests/GhsMulti/GhsMultiSrcGroups/resource.pdf @@ -1 +0,0 @@ - |