diff options
Diffstat (limited to 'Tests')
29 files changed, 95 insertions, 148 deletions
diff --git a/Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt b/Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt index f96283d..7dc7995 100644 --- a/Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt +++ b/Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt @@ -26,18 +26,18 @@ target_compile_definitions(consumer PRIVATE ) -if (CMAKE_GENERATOR MATCHES "Makefiles" OR CMAKE_GENERATOR MATCHES "Ninja") - target_sources(consumer PRIVATE - "${CMAKE_CURRENT_SOURCE_DIR}/consumer.c" - ) - target_compile_definitions(consumer - PRIVATE - CONSUMER_LANG_$<COMPILE_LANGUAGE> - LANG_IS_CXX=$<COMPILE_LANGUAGE:CXX> - LANG_IS_C=$<COMPILE_LANGUAGE:C> - ) +target_sources(consumer PRIVATE + "${CMAKE_CURRENT_SOURCE_DIR}/consumer.c" +) +target_compile_definitions(consumer + PRIVATE + CONSUMER_LANG_$<COMPILE_LANGUAGE> + LANG_IS_CXX=$<COMPILE_LANGUAGE:CXX> + LANG_IS_C=$<COMPILE_LANGUAGE:C> +) +if(CMAKE_GENERATOR MATCHES "Visual Studio|Xcode") target_compile_definitions(consumer - PRIVATE -DTEST_LANG_DEFINES + PRIVATE TEST_LANG_DEFINES_FOR_VISUAL_STUDIO_OR_XCODE ) endif() diff --git a/Tests/CMakeCommands/target_compile_definitions/consumer.c b/Tests/CMakeCommands/target_compile_definitions/consumer.c index 7931a6f..e134a8b 100644 --- a/Tests/CMakeCommands/target_compile_definitions/consumer.c +++ b/Tests/CMakeCommands/target_compile_definitions/consumer.c @@ -1,5 +1,23 @@ -#ifdef TEST_LANG_DEFINES +// Visual Studio allows only one set of flags for C and C++. +// In a target using C++ we pick the C++ flags even for C sources. +#ifdef TEST_LANG_DEFINES_FOR_VISUAL_STUDIO_OR_XCODE +#ifndef CONSUMER_LANG_CXX +#error Expected CONSUMER_LANG_CXX +#endif + +#ifdef CONSUMER_LANG_C +#error Unexpected CONSUMER_LANG_C +#endif + +#if !LANG_IS_CXX +#error Expected LANG_IS_CXX +#endif + +#if LANG_IS_C +#error Unexpected LANG_IS_C +#endif +#else #ifdef CONSUMER_LANG_CXX #error Unexpected CONSUMER_LANG_CXX #endif diff --git a/Tests/CMakeCommands/target_compile_definitions/consumer.cpp b/Tests/CMakeCommands/target_compile_definitions/consumer.cpp index 0202c17..69ea151 100644 --- a/Tests/CMakeCommands/target_compile_definitions/consumer.cpp +++ b/Tests/CMakeCommands/target_compile_definitions/consumer.cpp @@ -15,7 +15,6 @@ #error Expected DASH_D_DEFINE #endif -#ifdef TEST_LANG_DEFINES #ifndef CONSUMER_LANG_CXX #error Expected CONSUMER_LANG_CXX #endif @@ -31,7 +30,6 @@ #if LANG_IS_C #error Unexpected LANG_IS_C #endif -#endif int main() { diff --git a/Tests/CMakeCommands/target_include_directories/CMakeLists.txt b/Tests/CMakeCommands/target_include_directories/CMakeLists.txt index d57556a..8713d99 100644 --- a/Tests/CMakeCommands/target_include_directories/CMakeLists.txt +++ b/Tests/CMakeCommands/target_include_directories/CMakeLists.txt @@ -42,17 +42,17 @@ add_executable(consumer "${CMAKE_CURRENT_SOURCE_DIR}/consumer.cpp" ) -if (CMAKE_GENERATOR MATCHES "Makefiles" OR CMAKE_GENERATOR MATCHES "Ninja") - target_sources(consumer PRIVATE - "${CMAKE_CURRENT_SOURCE_DIR}/consumer.c" - ) - target_include_directories(consumer - PRIVATE - $<$<COMPILE_LANGUAGE:CXX>:${CMAKE_CURRENT_SOURCE_DIR}/cxx_only> - $<$<COMPILE_LANGUAGE:C>:${CMAKE_CURRENT_SOURCE_DIR}/c_only> - ) +target_sources(consumer PRIVATE + "${CMAKE_CURRENT_SOURCE_DIR}/consumer.c" +) +target_include_directories(consumer + PRIVATE + $<$<COMPILE_LANGUAGE:CXX>:${CMAKE_CURRENT_SOURCE_DIR}/cxx_only> + $<$<COMPILE_LANGUAGE:C>:${CMAKE_CURRENT_SOURCE_DIR}/c_only> +) +if(CMAKE_GENERATOR MATCHES "Visual Studio|Xcode") target_compile_definitions(consumer - PRIVATE -DTEST_LANG_DEFINES + PRIVATE TEST_LANG_DEFINES_FOR_VISUAL_STUDIO_OR_XCODE ) endif() diff --git a/Tests/CMakeCommands/target_include_directories/consumer.c b/Tests/CMakeCommands/target_include_directories/consumer.c index ae88f92..419c2d2 100644 --- a/Tests/CMakeCommands/target_include_directories/consumer.c +++ b/Tests/CMakeCommands/target_include_directories/consumer.c @@ -1,5 +1,13 @@ -#ifdef TEST_LANG_DEFINES +// Visual Studio allows only one set of flags for C and C++. +// In a target using C++ we pick the C++ flags even for C sources. +#ifdef TEST_LANG_DEFINES_FOR_VISUAL_STUDIO_OR_XCODE +#include "cxx_only.h" + +#ifndef CXX_ONLY_DEFINE +#error Expected CXX_ONLY_DEFINE +#endif +#else #include "c_only.h" #ifndef C_ONLY_DEFINE diff --git a/Tests/CMakeCommands/target_include_directories/consumer.cpp b/Tests/CMakeCommands/target_include_directories/consumer.cpp index 0f8153b..1e018ad 100644 --- a/Tests/CMakeCommands/target_include_directories/consumer.cpp +++ b/Tests/CMakeCommands/target_include_directories/consumer.cpp @@ -1,12 +1,10 @@ #include "consumer.h" #include "common.h" +#include "cxx_only.h" #include "interfaceinclude.h" #include "publicinclude.h" #include "relative_dir.h" -#ifdef TEST_LANG_DEFINES -#include "cxx_only.h" -#endif #ifdef PRIVATEINCLUDE_DEFINE #error Unexpected PRIVATEINCLUDE_DEFINE @@ -32,11 +30,9 @@ #error Expected CONSUMER_DEFINE #endif -#ifdef TEST_LANG_DEFINES #ifndef CXX_ONLY_DEFINE #error Expected CXX_ONLY_DEFINE #endif -#endif int main() { diff --git a/Tests/CudaOnly/WithDefs/CMakeLists.txt b/Tests/CudaOnly/WithDefs/CMakeLists.txt index 308c089..926d9ed 100644 --- a/Tests/CudaOnly/WithDefs/CMakeLists.txt +++ b/Tests/CudaOnly/WithDefs/CMakeLists.txt @@ -26,8 +26,8 @@ set_source_files_properties(main.notcu PROPERTIES LANGUAGE CUDA) target_compile_options(CudaOnlyWithDefs PRIVATE - -DCOMPILE_LANG_$<COMPILE_LANGUAGE> - -DLANG_IS_CUDA=$<COMPILE_LANGUAGE:CUDA> + -DFLAG_COMPILE_LANG_$<COMPILE_LANGUAGE> + -DFLAG_LANG_IS_CUDA=$<COMPILE_LANGUAGE:CUDA> -Xcompiler=-DHOST_DEFINE $<$<CONFIG:DEBUG>:$<BUILD_INTERFACE:${debug_compile_flags}>> ) @@ -35,8 +35,15 @@ target_compile_options(CudaOnlyWithDefs target_compile_definitions(CudaOnlyWithDefs PRIVATE $<$<CONFIG:RELEASE>:$<BUILD_INTERFACE:${release_compile_defs}>> + -DDEF_COMPILE_LANG_$<COMPILE_LANGUAGE> + -DDEF_LANG_IS_CUDA=$<COMPILE_LANGUAGE:CUDA> ) +target_include_directories(CudaOnlyWithDefs + PRIVATE + $<$<COMPILE_LANGUAGE:CUDA>:${CMAKE_CURRENT_SOURCE_DIR}/inc_cuda> +) + if(APPLE) # Help the static cuda runtime find the driver (libcuda.dyllib) at runtime. set_property(TARGET CudaOnlyWithDefs PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}) diff --git a/Tests/CudaOnly/WithDefs/inc_cuda/inc_cuda.h b/Tests/CudaOnly/WithDefs/inc_cuda/inc_cuda.h new file mode 100644 index 0000000..e228b58 --- /dev/null +++ b/Tests/CudaOnly/WithDefs/inc_cuda/inc_cuda.h @@ -0,0 +1 @@ +#define INC_CUDA diff --git a/Tests/CudaOnly/WithDefs/main.notcu b/Tests/CudaOnly/WithDefs/main.notcu index bfb3577..3793d74 100644 --- a/Tests/CudaOnly/WithDefs/main.notcu +++ b/Tests/CudaOnly/WithDefs/main.notcu @@ -2,6 +2,11 @@ #include <cuda_runtime.h> #include <iostream> +#include <inc_cuda.h> +#ifndef INC_CUDA +#error "INC_CUDA not defined!" +#endif + #ifndef HOST_DEFINE #error "HOST_DEFINE not defined!" #endif @@ -10,16 +15,28 @@ #error "PACKED_DEFINE not defined!" #endif -#ifndef COMPILE_LANG_CUDA -#error "COMPILE_LANG_CUDA not defined!" +#ifndef FLAG_COMPILE_LANG_CUDA +#error "FLAG_COMPILE_LANG_CUDA not defined!" +#endif + +#ifndef FLAG_LANG_IS_CUDA +#error "FLAG_LANG_IS_CUDA not defined!" +#endif + +#if !FLAG_LANG_IS_CUDA +#error "Expected FLAG_LANG_IS_CUDA" +#endif + +#ifndef DEF_COMPILE_LANG_CUDA +#error "DEF_COMPILE_LANG_CUDA not defined!" #endif -#ifndef LANG_IS_CUDA -#error "LANG_IS_CUDA not defined!" +#ifndef DEF_LANG_IS_CUDA +#error "DEF_LANG_IS_CUDA not defined!" #endif -#if !LANG_IS_CUDA -#error "Expected LANG_IS_CUDA" +#if !DEF_LANG_IS_CUDA +#error "Expected DEF_LANG_IS_CUDA" #endif static __global__ void DetermineIfValidCudaDevice() diff --git a/Tests/GeneratorExpression/CMakeLists.txt b/Tests/GeneratorExpression/CMakeLists.txt index 0585d0c..4586357 100644 --- a/Tests/GeneratorExpression/CMakeLists.txt +++ b/Tests/GeneratorExpression/CMakeLists.txt @@ -269,10 +269,8 @@ set_property(SOURCE srcgenex_flags_COMPILE_LANGUAGE.c PROPERTY COMPILE_FLAGS "$< add_executable(srcgenex_defs srcgenex_defs.c) set_property(SOURCE srcgenex_defs.c PROPERTY COMPILE_DEFINITIONS NAME=$<TARGET_PROPERTY:NAME>) -if (CMAKE_GENERATOR MATCHES "Makefiles|Ninja|Watcom WMake") - add_executable(srcgenex_defs_COMPILE_LANGUAGE srcgenex_defs_COMPILE_LANGUAGE.c) - set_property(SOURCE srcgenex_defs_COMPILE_LANGUAGE.c PROPERTY COMPILE_DEFINITIONS $<$<COMPILE_LANGUAGE:C>:NAME=$<TARGET_PROPERTY:NAME>>) -endif() +add_executable(srcgenex_defs_COMPILE_LANGUAGE srcgenex_defs_COMPILE_LANGUAGE.c) +set_property(SOURCE srcgenex_defs_COMPILE_LANGUAGE.c PROPERTY COMPILE_DEFINITIONS $<$<COMPILE_LANGUAGE:C>:NAME=$<TARGET_PROPERTY:NAME>>) #----------------------------------------------------------------------------- # Cover test properties with generator expressions. diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 8eb8568..edd6c79 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -351,8 +351,6 @@ add_RunCMake_test(IfacePaths_INCLUDE_DIRECTORIES TEST_DIR IfacePaths) set(IfacePaths_SOURCES_ARGS -DTEST_PROP=SOURCES) add_RunCMake_test(IfacePaths_SOURCES TEST_DIR IfacePaths) -add_RunCMake_test(COMPILE_LANGUAGE-genex) - # Matlab module related tests if(CMake_TEST_FindMatlab) add_RunCMake_test(FindMatlab) diff --git a/Tests/RunCMake/COMPILE_LANGUAGE-genex/CMakeLists.txt b/Tests/RunCMake/COMPILE_LANGUAGE-genex/CMakeLists.txt deleted file mode 100644 index ef2163c..0000000 --- a/Tests/RunCMake/COMPILE_LANGUAGE-genex/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -cmake_minimum_required(VERSION 3.1) -project(${RunCMake_TEST} NONE) -include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/COMPILE_LANGUAGE-genex/CompileDefinitions-result.txt b/Tests/RunCMake/COMPILE_LANGUAGE-genex/CompileDefinitions-result.txt deleted file mode 100644 index d00491f..0000000 --- a/Tests/RunCMake/COMPILE_LANGUAGE-genex/CompileDefinitions-result.txt +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/Tests/RunCMake/COMPILE_LANGUAGE-genex/CompileDefinitions-stderr-VS.txt b/Tests/RunCMake/COMPILE_LANGUAGE-genex/CompileDefinitions-stderr-VS.txt deleted file mode 100644 index 42c1485..0000000 --- a/Tests/RunCMake/COMPILE_LANGUAGE-genex/CompileDefinitions-stderr-VS.txt +++ /dev/null @@ -1,9 +0,0 @@ -CMake Error at CompileDefinitions.cmake:5 \(target_compile_definitions\): - Error evaluating generator expression: - - \$<COMPILE_LANGUAGE:CXX> - - \$<COMPILE_LANGUAGE:...> may only be used for COMPILE_OPTIONS and - file\(GENERATE\) with the Visual Studio generator. -Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/COMPILE_LANGUAGE-genex/CompileDefinitions-stderr-Xcode.txt b/Tests/RunCMake/COMPILE_LANGUAGE-genex/CompileDefinitions-stderr-Xcode.txt deleted file mode 100644 index 7879a79..0000000 --- a/Tests/RunCMake/COMPILE_LANGUAGE-genex/CompileDefinitions-stderr-Xcode.txt +++ /dev/null @@ -1,9 +0,0 @@ -CMake Error at CompileDefinitions.cmake:5 \(target_compile_definitions\): - Error evaluating generator expression: - - \$<COMPILE_LANGUAGE:CXX> - - \$<COMPILE_LANGUAGE:...> may only be used for COMPILE_OPTIONS and - file\(GENERATE\) with the Xcode generator. -Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/COMPILE_LANGUAGE-genex/CompileDefinitions.cmake b/Tests/RunCMake/COMPILE_LANGUAGE-genex/CompileDefinitions.cmake deleted file mode 100644 index 7935d88..0000000 --- a/Tests/RunCMake/COMPILE_LANGUAGE-genex/CompileDefinitions.cmake +++ /dev/null @@ -1,5 +0,0 @@ - -enable_language(CXX) - -add_executable(main main.cpp) -target_compile_definitions(main PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-DANYTHING>) diff --git a/Tests/RunCMake/COMPILE_LANGUAGE-genex/IncludeDirectories-result.txt b/Tests/RunCMake/COMPILE_LANGUAGE-genex/IncludeDirectories-result.txt deleted file mode 100644 index d00491f..0000000 --- a/Tests/RunCMake/COMPILE_LANGUAGE-genex/IncludeDirectories-result.txt +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/Tests/RunCMake/COMPILE_LANGUAGE-genex/IncludeDirectories-stderr-VS.txt b/Tests/RunCMake/COMPILE_LANGUAGE-genex/IncludeDirectories-stderr-VS.txt deleted file mode 100644 index 3806ed1..0000000 --- a/Tests/RunCMake/COMPILE_LANGUAGE-genex/IncludeDirectories-stderr-VS.txt +++ /dev/null @@ -1,9 +0,0 @@ -CMake Error at IncludeDirectories.cmake:5 \(target_include_directories\): - Error evaluating generator expression: - - \$<COMPILE_LANGUAGE:CXX> - - \$<COMPILE_LANGUAGE:...> may only be used for COMPILE_OPTIONS and - file\(GENERATE\) with the Visual Studio generator. -Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/COMPILE_LANGUAGE-genex/IncludeDirectories-stderr-Xcode.txt b/Tests/RunCMake/COMPILE_LANGUAGE-genex/IncludeDirectories-stderr-Xcode.txt deleted file mode 100644 index a3fb9c5..0000000 --- a/Tests/RunCMake/COMPILE_LANGUAGE-genex/IncludeDirectories-stderr-Xcode.txt +++ /dev/null @@ -1,9 +0,0 @@ -CMake Error at IncludeDirectories.cmake:5 \(target_include_directories\): - Error evaluating generator expression: - - \$<COMPILE_LANGUAGE:CXX> - - \$<COMPILE_LANGUAGE:...> may only be used for COMPILE_OPTIONS and - file\(GENERATE\) with the Xcode generator. -Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/COMPILE_LANGUAGE-genex/IncludeDirectories.cmake b/Tests/RunCMake/COMPILE_LANGUAGE-genex/IncludeDirectories.cmake deleted file mode 100644 index 31771f6..0000000 --- a/Tests/RunCMake/COMPILE_LANGUAGE-genex/IncludeDirectories.cmake +++ /dev/null @@ -1,5 +0,0 @@ - -enable_language(CXX) - -add_executable(main main.cpp) -target_include_directories(main PRIVATE $<$<COMPILE_LANGUAGE:CXX>:anydir>) diff --git a/Tests/RunCMake/COMPILE_LANGUAGE-genex/PerSourceCompileDefinitions-result.txt b/Tests/RunCMake/COMPILE_LANGUAGE-genex/PerSourceCompileDefinitions-result.txt deleted file mode 100644 index d00491f..0000000 --- a/Tests/RunCMake/COMPILE_LANGUAGE-genex/PerSourceCompileDefinitions-result.txt +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/Tests/RunCMake/COMPILE_LANGUAGE-genex/PerSourceCompileDefinitions-stderr-VS.txt b/Tests/RunCMake/COMPILE_LANGUAGE-genex/PerSourceCompileDefinitions-stderr-VS.txt deleted file mode 100644 index 5d19153..0000000 --- a/Tests/RunCMake/COMPILE_LANGUAGE-genex/PerSourceCompileDefinitions-stderr-VS.txt +++ /dev/null @@ -1,7 +0,0 @@ -CMake Error: - Error evaluating generator expression: - - \$<COMPILE_LANGUAGE:CXX> - - \$<COMPILE_LANGUAGE:...> may only be used for COMPILE_OPTIONS and - file\(GENERATE\) with the Visual Studio generator. diff --git a/Tests/RunCMake/COMPILE_LANGUAGE-genex/PerSourceCompileDefinitions-stderr-Xcode.txt b/Tests/RunCMake/COMPILE_LANGUAGE-genex/PerSourceCompileDefinitions-stderr-Xcode.txt deleted file mode 100644 index 4a4564e..0000000 --- a/Tests/RunCMake/COMPILE_LANGUAGE-genex/PerSourceCompileDefinitions-stderr-Xcode.txt +++ /dev/null @@ -1,7 +0,0 @@ -CMake Error: - Error evaluating generator expression: - - \$<COMPILE_LANGUAGE:CXX> - - \$<COMPILE_LANGUAGE:...> may only be used for COMPILE_OPTIONS and - file\(GENERATE\) with the Xcode generator. diff --git a/Tests/RunCMake/COMPILE_LANGUAGE-genex/PerSourceCompileDefinitions.cmake b/Tests/RunCMake/COMPILE_LANGUAGE-genex/PerSourceCompileDefinitions.cmake deleted file mode 100644 index 3a07d7d..0000000 --- a/Tests/RunCMake/COMPILE_LANGUAGE-genex/PerSourceCompileDefinitions.cmake +++ /dev/null @@ -1,5 +0,0 @@ - -enable_language(CXX) - -add_executable(main main.cpp) -set_property(SOURCE main.cpp PROPERTY COMPILE_DEFINITIONS $<$<COMPILE_LANGUAGE:CXX>:ANYTHING>) diff --git a/Tests/RunCMake/COMPILE_LANGUAGE-genex/RunCMakeTest.cmake b/Tests/RunCMake/COMPILE_LANGUAGE-genex/RunCMakeTest.cmake deleted file mode 100644 index 1a93dcd..0000000 --- a/Tests/RunCMake/COMPILE_LANGUAGE-genex/RunCMakeTest.cmake +++ /dev/null @@ -1,23 +0,0 @@ -include(RunCMake) - -if (RunCMake_GENERATOR STREQUAL "Xcode") - set(RunCMake-stderr-file CompileDefinitions-stderr-Xcode.txt) - run_cmake(CompileDefinitions) -elseif (RunCMake_GENERATOR MATCHES "Visual Studio") - set(RunCMake-stderr-file CompileDefinitions-stderr-VS.txt) - run_cmake(CompileDefinitions) -endif() -if (RunCMake_GENERATOR STREQUAL "Xcode") - set(RunCMake-stderr-file IncludeDirectories-stderr-Xcode.txt) - run_cmake(IncludeDirectories) -elseif (RunCMake_GENERATOR MATCHES "Visual Studio") - set(RunCMake-stderr-file IncludeDirectories-stderr-VS.txt) - run_cmake(IncludeDirectories) -endif() -if (RunCMake_GENERATOR STREQUAL "Xcode") - set(RunCMake-stderr-file PerSourceCompileDefinitions-stderr-Xcode.txt) - run_cmake(PerSourceCompileDefinitions) -elseif (RunCMake_GENERATOR MATCHES "Visual Studio") - set(RunCMake-stderr-file PerSourceCompileDefinitions-stderr-VS.txt) - run_cmake(PerSourceCompileDefinitions) -endif() diff --git a/Tests/RunCMake/COMPILE_LANGUAGE-genex/main.cpp b/Tests/RunCMake/COMPILE_LANGUAGE-genex/main.cpp deleted file mode 100644 index 766b775..0000000 --- a/Tests/RunCMake/COMPILE_LANGUAGE-genex/main.cpp +++ /dev/null @@ -1,5 +0,0 @@ - -int main() -{ - return 0; -} diff --git a/Tests/RunCMake/GenerateExportHeader/GEH.cmake b/Tests/RunCMake/GenerateExportHeader/GEH.cmake index cfca8fe..cf81f36 100644 --- a/Tests/RunCMake/GenerateExportHeader/GEH.cmake +++ b/Tests/RunCMake/GenerateExportHeader/GEH.cmake @@ -53,7 +53,16 @@ endif() add_subdirectory(lib_shared_and_static) -add_compiler_export_flags() +if(CMAKE_SYSTEM_NAME MATCHES "AIX" AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU" + AND CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY) + # With GNU 7 on AIX, passing -fvisibility=hidden when driving the + # linker for a shared library drops the so init/destruct symbols. + # Just use the modern approach instead of testing the macro. + set(CMAKE_CXX_VISIBILITY_PRESET hidden) + set(CMAKE_VISIBILITY_INLINES_HIDDEN 1) +else() + add_compiler_export_flags() +endif() set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/Tests/RunCMake/GenerateExportHeader/libshared/CMakeLists.txt b/Tests/RunCMake/GenerateExportHeader/libshared/CMakeLists.txt index c4a761c..9516a5a 100644 --- a/Tests/RunCMake/GenerateExportHeader/libshared/CMakeLists.txt +++ b/Tests/RunCMake/GenerateExportHeader/libshared/CMakeLists.txt @@ -1,7 +1,5 @@ include(GenerateExportHeader) -add_compiler_export_flags() - set(CMAKE_INCLUDE_CURRENT_DIR ON) add_library(libshared SHARED libshared.cpp) diff --git a/Tests/RunCMake/GenerateExportHeader/libstatic/CMakeLists.txt b/Tests/RunCMake/GenerateExportHeader/libstatic/CMakeLists.txt index 0fd136c..56e8335 100644 --- a/Tests/RunCMake/GenerateExportHeader/libstatic/CMakeLists.txt +++ b/Tests/RunCMake/GenerateExportHeader/libstatic/CMakeLists.txt @@ -2,8 +2,6 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) include(GenerateExportHeader) -add_compiler_export_flags() - # Show that the export header has no effect on a static library. add_library(libstatic STATIC libstatic.cpp) |