Merge topic 'test-GenerateExportHeader-with-RunCMake'

72ecdd34 Tests: Cleanup RunCMake.GenerateExportHeader somewhat
fc3dab0e Tests: Port GenerateExportHeader test to RunCMake infrastructure
4feba34d GNU: Do not use -fvisibility on AIX or HP-UX
This commit is contained in:
Brad King 2016-09-06 08:51:01 -04:00 committed by CMake Topic Stage
commit 9109ba4347
44 changed files with 43 additions and 51 deletions

View File

@ -1,2 +1,3 @@
include(Platform/AIX-GNU) include(Platform/AIX-GNU)
__aix_compiler_gnu(CXX) __aix_compiler_gnu(CXX)
unset(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN)

View File

@ -34,4 +34,5 @@ macro(__aix_compiler_gnu lang)
set(CMAKE_${lang}_USE_IMPLICIT_LINK_DIRECTORIES_IN_RUNTIME_PATH 1) set(CMAKE_${lang}_USE_IMPLICIT_LINK_DIRECTORIES_IN_RUNTIME_PATH 1)
set(CMAKE_${lang}_LINK_FLAGS "-Wl,-bnoipath") set(CMAKE_${lang}_LINK_FLAGS "-Wl,-bnoipath")
unset(CMAKE_${lang}_COMPILE_OPTIONS_VISIBILITY)
endmacro() endmacro()

View File

@ -1,2 +1,3 @@
include(Platform/HP-UX-GNU) include(Platform/HP-UX-GNU)
__hpux_compiler_gnu(CXX) __hpux_compiler_gnu(CXX)
unset(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN)

View File

@ -26,4 +26,5 @@ macro(__hpux_compiler_gnu lang)
set(CMAKE_SHARED_LIBRARY_SONAME_${lang}_FLAG "-Wl,+h") set(CMAKE_SHARED_LIBRARY_SONAME_${lang}_FLAG "-Wl,+h")
set(CMAKE_${lang}_LINK_FLAGS "-Wl,+s,+nodefaultrpath") set(CMAKE_${lang}_LINK_FLAGS "-Wl,+s,+nodefaultrpath")
unset(CMAKE_${lang}_COMPILE_OPTIONS_VISIBILITY)
endmacro() endmacro()

View File

@ -485,7 +485,6 @@ if(BUILD_TESTING)
) )
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Module/ExternalData") list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Module/ExternalData")
ADD_TEST_MACRO(Module.GenerateExportHeader GenerateExportHeader)
ADD_TEST_MACRO(Module.FindDependency FindDependency) ADD_TEST_MACRO(Module.FindDependency FindDependency)
ADD_TEST_MACRO(Module.WriteCompilerDetectionHeader WriteCompilerDetectionHeader) ADD_TEST_MACRO(Module.WriteCompilerDetectionHeader WriteCompilerDetectionHeader)

View File

@ -141,6 +141,9 @@ add_RunCMake_test(DisallowedCommands)
add_RunCMake_test(ExternalData) add_RunCMake_test(ExternalData)
add_RunCMake_test(FeatureSummary) add_RunCMake_test(FeatureSummary)
add_RunCMake_test(FPHSA) add_RunCMake_test(FPHSA)
if(NOT CMAKE_C_COMPILER_ID MATCHES "Watcom")
add_RunCMake_test(GenerateExportHeader)
endif()
add_RunCMake_test(GeneratorExpression) add_RunCMake_test(GeneratorExpression)
add_RunCMake_test(GeneratorPlatform) add_RunCMake_test(GeneratorPlatform)
add_RunCMake_test(GeneratorToolset) add_RunCMake_test(GeneratorToolset)

View File

@ -0,0 +1,3 @@
cmake_minimum_required(VERSION 3.6)
project(${RunCMake_TEST} NONE)
include(${RunCMake_TEST}.cmake)

View File

@ -0,0 +1 @@
.*

View File

@ -1,23 +1,8 @@
cmake_minimum_required(VERSION 2.8.5 FATAL_ERROR) # Test add_compiler_export_flags without deprecation warning.
cmake_policy(SET CMP0054 NEW) set(CMAKE_WARN_DEPRECATED OFF)
project(GenerateExportHeader) project(GenerateExportHeader)
# Prevent timeout on Watcom by not running the tests.
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES Watcom)
file(WRITE
"${CMAKE_CURRENT_BINARY_DIR}/main.cxx"
"int main() { return 0; }
"
)
add_executable(
GenerateExportHeader
"${CMAKE_CURRENT_BINARY_DIR}/main.cxx"
)
return()
endif()
include(CheckCXXCompilerFlag) include(CheckCXXCompilerFlag)
set( CMAKE_INCLUDE_CURRENT_DIR ON ) set( CMAKE_INCLUDE_CURRENT_DIR ON )
@ -78,17 +63,18 @@ add_subdirectory(lib_shared_and_static)
add_compiler_export_flags() add_compiler_export_flags()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_CURRENT_BINARY_DIR})
message("#### COMPILER_HAS_DEPRECATED: " ${COMPILER_HAS_DEPRECATED}) message(STATUS "COMPILER_HAS_DEPRECATED: " ${COMPILER_HAS_DEPRECATED})
message("#### COMPILER_HAS_HIDDEN_VISIBILITY: " ${COMPILER_HAS_HIDDEN_VISIBILITY}) message(STATUS "COMPILER_HAS_HIDDEN_VISIBILITY: " ${COMPILER_HAS_HIDDEN_VISIBILITY})
message("#### WIN32: " ${WIN32}) message(STATUS "WIN32: " ${WIN32})
message("#### HAS_WERROR_FLAG: " ${HAS_WERROR_FLAG}) message(STATUS "HAS_WERROR_FLAG: " ${HAS_WERROR_FLAG})
set(link_libraries) set(link_libraries)
macro(macro_add_test_library name) macro(macro_add_test_library name)
add_subdirectory(${name}) add_subdirectory(${name})
include_directories(${name} include_directories(${name}
${${name}_BINARY_DIR} # For the export header. ${CMAKE_CURRENT_BINARY_DIR}/${name} # For the export header.
) )
list(APPEND link_libraries ${name}) list(APPEND link_libraries ${name})
endmacro() endmacro()
@ -131,7 +117,7 @@ elseif(COMPILER_HAS_DEPRECATED)
else() else()
set(_platform Empty) set(_platform Empty)
endif() endif()
message("#### Testing reference: ${_platform}") message(STATUS "Testing reference: ${_platform}")
target_compile_definitions(GenerateExportHeader target_compile_definitions(GenerateExportHeader
PRIVATE PRIVATE
"SRC_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}/reference/${_platform}\"" "SRC_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}/reference/${_platform}\""

View File

@ -0,0 +1,17 @@
include(RunCMake)
function(run_GEH)
# Use a single build tree for a few tests without cleaning.
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/GEH-build)
set(RunCMake_TEST_NO_CLEAN 1)
if(RunCMake_GENERATOR MATCHES "Make|Ninja")
set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug)
endif()
file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
run_cmake(GEH)
run_cmake_command(GEH-build ${CMAKE_COMMAND} --build . --config Debug)
run_cmake_command(GEH-run ${RunCMake_TEST_BINARY_DIR}/GenerateExportHeader)
endfunction()
run_GEH()

View File

@ -1,5 +1,3 @@
project(c_identifier)
set(c_identifier_lib_SRCS set(c_identifier_lib_SRCS
c_identifier_class.cpp c_identifier_class.cpp
) )

View File

@ -1,7 +1,7 @@
#include "c_identifier_class.h" #include "c_identifier_class.h"
int main(int argc, char** argv) int main()
{ {
CIdentifierClass cic; CIdentifierClass cic;
return cic.someMethod(); return cic.someMethod();

View File

@ -1,8 +1,3 @@
cmake_minimum_required(VERSION 2.8)
project(lib_shared_and_static)
include(GenerateExportHeader) include(GenerateExportHeader)
set(CMAKE_CXX_VISIBILITY_PRESET hidden) set(CMAKE_CXX_VISIBILITY_PRESET hidden)
@ -33,6 +28,6 @@ generate_export_header(shared_variant
CUSTOM_CONTENT_FROM_VARIABLE MY_CUSTOM_CONTENT CUSTOM_CONTENT_FROM_VARIABLE MY_CUSTOM_CONTENT
) )
set_target_properties(static_variant PROPERTIES COMPILE_FLAGS -DLIBSHARED_AND_STATIC_STATIC_DEFINE) target_compile_definitions(static_variant PUBLIC MYPREFIX_LIBSHARED_AND_STATIC_STATIC_DEFINE)
export(TARGETS shared_variant static_variant FILE Targets.cmake) export(TARGETS shared_variant static_variant FILE Targets.cmake)

View File

@ -1,8 +1,3 @@
cmake_minimum_required(VERSION 2.8)
project(libshared)
include(GenerateExportHeader) include(GenerateExportHeader)
add_compiler_export_flags() add_compiler_export_flags()

View File

@ -1,8 +1,3 @@
cmake_minimum_required(VERSION 2.8)
project(libstatic)
set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_INCLUDE_CURRENT_DIR ON)
include(GenerateExportHeader) include(GenerateExportHeader)

View File

@ -1,7 +1,3 @@
cmake_minimum_required(VERSION 2.8)
project(nodeprecated)
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR}/nodeprecated_defined) execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR}/nodeprecated_defined)
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR}/nodeprecated_not_defined) execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR}/nodeprecated_not_defined)
@ -23,4 +19,4 @@ try_compile(Result ${CMAKE_CURRENT_BINARY_DIR}/nodeprecated_defined_build
OUTPUT_VARIABLE Out OUTPUT_VARIABLE Out
) )
test_fail(Result "Built even with no-deprecated define") test_fail(Result "Built even with no-deprecated define")

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 2.8) cmake_minimum_required(VERSION 3.6)
project(nodeprecated_test) project(nodeprecated_test)

View File

@ -1,7 +1,7 @@
#include "someclass.h" #include "someclass.h"
int main(int, char**) int main()
{ {
SomeClass sc; SomeClass sc;
sc.someMethod(); sc.someMethod();

View File

@ -126,7 +126,7 @@ $git_ls -z -- '*.c' '*.cc' '*.cpp' '*.cxx' '*.h' '*.hh' '*.hpp' '*.hxx' |
egrep -z -v '^Utilities/(KW|cm).*/' | egrep -z -v '^Utilities/(KW|cm).*/' |
# Exclude reference content. # Exclude reference content.
egrep -z -v '^Tests/Module/GenerateExportHeader/reference/' | egrep -z -v '^Tests/RunCMake/GenerateExportHeader/reference/' |
# Exclude manually-formatted sources (e.g. with long lines). # Exclude manually-formatted sources (e.g. with long lines).
egrep -z -v '^Tests/PositionIndependentTargets/pic_test.h' | egrep -z -v '^Tests/PositionIndependentTargets/pic_test.h' |