Commit 72ecdd34 authored by Brad King's avatar Brad King
Browse files

Tests: Cleanup RunCMake.GenerateExportHeader somewhat

parent fc3dab0e
Pipeline #24727 passed with stage
cmake_minimum_required(VERSION 2.8.5)
cmake_minimum_required(VERSION 3.6)
project(${RunCMake_TEST} NONE)
include(${RunCMake_TEST}.cmake)
cmake_minimum_required(VERSION 2.8.5 FATAL_ERROR)
cmake_policy(SET CMP0054 NEW)
# Test add_compiler_export_flags without deprecation warning.
set(CMAKE_WARN_DEPRECATED OFF)
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)
set( CMAKE_INCLUDE_CURRENT_DIR ON )
......@@ -80,16 +65,16 @@ add_compiler_export_flags()
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("#### COMPILER_HAS_HIDDEN_VISIBILITY: " ${COMPILER_HAS_HIDDEN_VISIBILITY})
message("#### WIN32: " ${WIN32})
message("#### HAS_WERROR_FLAG: " ${HAS_WERROR_FLAG})
message(STATUS "COMPILER_HAS_DEPRECATED: " ${COMPILER_HAS_DEPRECATED})
message(STATUS "COMPILER_HAS_HIDDEN_VISIBILITY: " ${COMPILER_HAS_HIDDEN_VISIBILITY})
message(STATUS "WIN32: " ${WIN32})
message(STATUS "HAS_WERROR_FLAG: " ${HAS_WERROR_FLAG})
set(link_libraries)
macro(macro_add_test_library name)
add_subdirectory(${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})
endmacro()
......@@ -132,7 +117,7 @@ elseif(COMPILER_HAS_DEPRECATED)
else()
set(_platform Empty)
endif()
message("#### Testing reference: ${_platform}")
message(STATUS "Testing reference: ${_platform}")
target_compile_definitions(GenerateExportHeader
PRIVATE
"SRC_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}/reference/${_platform}\""
......
project(c_identifier)
set(c_identifier_lib_SRCS
c_identifier_class.cpp
)
......
#include "c_identifier_class.h"
int main(int argc, char** argv)
int main()
{
CIdentifierClass cic;
return cic.someMethod();
......
cmake_minimum_required(VERSION 2.8)
project(lib_shared_and_static)
include(GenerateExportHeader)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
......@@ -33,6 +28,6 @@ generate_export_header(shared_variant
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)
cmake_minimum_required(VERSION 2.8)
project(libshared)
include(GenerateExportHeader)
add_compiler_export_flags()
......
cmake_minimum_required(VERSION 2.8)
project(libstatic)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
include(GenerateExportHeader)
......
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_not_defined)
......@@ -23,4 +19,4 @@ try_compile(Result ${CMAKE_CURRENT_BINARY_DIR}/nodeprecated_defined_build
OUTPUT_VARIABLE Out
)
test_fail(Result "Built even with no-deprecated define")
\ No newline at end of file
test_fail(Result "Built even with no-deprecated define")
cmake_minimum_required(VERSION 2.8)
cmake_minimum_required(VERSION 3.6)
project(nodeprecated_test)
......
#include "someclass.h"
int main(int, char**)
int main()
{
SomeClass sc;
sc.someMethod();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment