diff options
author | David Cole <david.cole@kitware.com> | 2011-10-11 18:45:31 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2011-10-11 18:45:31 (GMT) |
commit | d9f996334bae5c5bd6ceecaa71dd5ed64261a596 (patch) | |
tree | 427033950f90370668087c9201b66e5168d20386 | |
parent | c8e92de286cd86c0a808e8a1c7a81dc9481c6153 (diff) | |
parent | 08271ec7d3184c8a53ae80be9ec0ac6438032cfa (diff) | |
download | CMake-d9f996334bae5c5bd6ceecaa71dd5ed64261a596.zip CMake-d9f996334bae5c5bd6ceecaa71dd5ed64261a596.tar.gz CMake-d9f996334bae5c5bd6ceecaa71dd5ed64261a596.tar.bz2 |
Merge topic 'export-header-tests'
08271ec Build each library only once instead of once for each test.
c83cfd7 Remove unused define.
4 files changed, 58 insertions, 13 deletions
diff --git a/Tests/Module/GenerateExportHeader/CMakeLists.txt b/Tests/Module/GenerateExportHeader/CMakeLists.txt index 3edb548..4a5b1cb 100644 --- a/Tests/Module/GenerateExportHeader/CMakeLists.txt +++ b/Tests/Module/GenerateExportHeader/CMakeLists.txt @@ -55,6 +55,29 @@ else() endif() endif() +set(DEPS + libshared + libstatic + lib_shared_and_static +) + +foreach(DEP ${DEPS}) + try_compile(Result ${CMAKE_CURRENT_BINARY_DIR}/${DEP}_build + ${CMAKE_CURRENT_SOURCE_DIR}/${DEP} + ${DEP} + OUTPUT_VARIABLE Out + ) + if (NOT Result) + message("OUTPUT: ${Out}") + endif() +endforeach() + +# The _do_build macro is called from a child scope, where +# the current source and binary dir are different. Save them here +# for use in the macro. +set(TEST_TOP_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) +set(TEST_TOP_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) + # We seem to get race conditions is writing this stuff to the same file at least on MinGW # So to write to separate source and build directories, we use a count to differentiate. @@ -67,8 +90,6 @@ macro(_do_build Include Library LibrarySource Source) "int main() { ${Source}; }\n" ) - file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/../${LibrarySource}" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/test${COUNT}") - if ("${Library}" STREQUAL "static_variant") set(CONDITIONAL_STATIC_DEFINE "add_definitions(-DLIBSHARED_AND_STATIC_STATIC_DEFINE)\n") endif() @@ -90,13 +111,10 @@ macro(_do_build Include Library LibrarySource Source) " add_definitions(${ERROR_FLAG})\n" "endif()\n" - "if(MSVC)\n" - " add_definitions(-DCOMPILER_IS_MSVC)\n" - "endif()\n" - - "add_subdirectory(\"${LibrarySource}\")\n" + "include(\"${TEST_TOP_BINARY_DIR}/${LibrarySource}_build/Targets.cmake\")\n" - "include_directories(\"${LibrarySource}\" \"\${CMAKE_CURRENT_BINARY_DIR}/${LibrarySource}\")\n" + "include_directories(\"${TEST_TOP_SOURCE_DIR}/${LibrarySource}\"\n" + " \"${TEST_TOP_BINARY_DIR}/${LibrarySource}_build\")\n" "${CONDITIONAL_STATIC_DEFINE}" @@ -125,10 +143,6 @@ include(GenerateExportHeader) add_compiler_export_flags() -if (MSVC) - add_definitions(-DCOMPILER_IS_MSVC) -endif() - set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) message("#### COMPILER_HAS_DEPRECATED: " ${COMPILER_HAS_DEPRECATED}) diff --git a/Tests/Module/GenerateExportHeader/lib_shared_and_static/CMakeLists.txt b/Tests/Module/GenerateExportHeader/lib_shared_and_static/CMakeLists.txt index d19b6dc..be0387f 100644 --- a/Tests/Module/GenerateExportHeader/lib_shared_and_static/CMakeLists.txt +++ b/Tests/Module/GenerateExportHeader/lib_shared_and_static/CMakeLists.txt @@ -1,4 +1,13 @@ -project(shared_and_static) + +cmake_minimum_required(VERSION 2.8) + +project(lib_shared_and_static) + +include(GenerateExportHeader) + +add_compiler_export_flags() + +set(CMAKE_INCLUDE_CURRENT_DIR ON) set(lib_SRCS libshared_and_static.cpp @@ -10,3 +19,5 @@ add_library(static_variant ${lib_SRCS}) generate_export_header(shared_variant BASE_NAME libshared_and_static) set_target_properties(static_variant PROPERTIES COMPILE_FLAGS -DLIBSHARED_AND_STATIC_STATIC_DEFINE) + +export(TARGETS shared_variant static_variant FILE Targets.cmake) diff --git a/Tests/Module/GenerateExportHeader/libshared/CMakeLists.txt b/Tests/Module/GenerateExportHeader/libshared/CMakeLists.txt index 8e4ee2b..e20adb1 100644 --- a/Tests/Module/GenerateExportHeader/libshared/CMakeLists.txt +++ b/Tests/Module/GenerateExportHeader/libshared/CMakeLists.txt @@ -1,6 +1,16 @@ +cmake_minimum_required(VERSION 2.8) + project(libshared) +include(GenerateExportHeader) + +add_compiler_export_flags() + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + add_library(libshared SHARED libshared.cpp) generate_export_header(libshared) + +export(TARGETS libshared FILE Targets.cmake) diff --git a/Tests/Module/GenerateExportHeader/libstatic/CMakeLists.txt b/Tests/Module/GenerateExportHeader/libstatic/CMakeLists.txt index 8db1827..b2db3ea 100644 --- a/Tests/Module/GenerateExportHeader/libstatic/CMakeLists.txt +++ b/Tests/Module/GenerateExportHeader/libstatic/CMakeLists.txt @@ -1,8 +1,18 @@ +cmake_minimum_required(VERSION 2.8) + project(libstatic) +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) generate_export_header(libstatic) + +export(TARGETS libstatic FILE Targets.cmake) |