diff options
7 files changed, 44 insertions, 1 deletions
diff --git a/Modules/GenerateExportHeader.cmake b/Modules/GenerateExportHeader.cmake index c717899..3665817 100644 --- a/Modules/GenerateExportHeader.cmake +++ b/Modules/GenerateExportHeader.cmake @@ -188,6 +188,12 @@ macro(_DO_GENERATE_EXPORT_HEADER TARGET_LIBRARY) set(INCLUDE_GUARD_NAME "${PREFIX}${EXPORT_MACRO_NAME}_H") + get_target_property(EXPORT_IMPORT_CONDITION ${TARGET_LIBRARY} DEFINE_SYMBOL) + + if (NOT EXPORT_IMPORT_CONDITION) + set(EXPORT_IMPORT_CONDITION ${TARGET_LIBRARY}_EXPORTS) + endif() + configure_file(${myDir}/exportheader.cmake.in ${EXPORT_FILE_NAME} @ONLY) endmacro() diff --git a/Modules/exportheader.cmake.in b/Modules/exportheader.cmake.in index 083e95c..62ed3ff 100644 --- a/Modules/exportheader.cmake.in +++ b/Modules/exportheader.cmake.in @@ -7,7 +7,7 @@ # define @NO_EXPORT_MACRO_NAME@ #else # ifndef @EXPORT_MACRO_NAME@ -# ifdef @TARGET_LIBRARY@_EXPORTS +# ifdef @EXPORT_IMPORT_CONDITION@ /* We are building this library */ # define @EXPORT_MACRO_NAME@ @DEFINE_EXPORT@ # else diff --git a/Tests/Module/GenerateExportHeader/CMakeLists.txt b/Tests/Module/GenerateExportHeader/CMakeLists.txt index 2d6eabe..4570280 100644 --- a/Tests/Module/GenerateExportHeader/CMakeLists.txt +++ b/Tests/Module/GenerateExportHeader/CMakeLists.txt @@ -107,6 +107,8 @@ macro_add_test_library(libstatic) add_subdirectory(lib_shared_and_static) add_subdirectory(lib_shared_and_statictest) +add_subdirectory(override_symbol) + if (CMAKE_COMPILER_IS_GNUCXX) # We deliberately call deprecated methods, and test for that elsewhere. # No need to clutter the test output with warnings. diff --git a/Tests/Module/GenerateExportHeader/override_symbol/CMakeLists.txt b/Tests/Module/GenerateExportHeader/override_symbol/CMakeLists.txt new file mode 100644 index 0000000..aeeef20 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/override_symbol/CMakeLists.txt @@ -0,0 +1,11 @@ +project(override_symbol) + +add_library(somelib SHARED someclass.cpp) + +set_target_properties(somelib PROPERTIES DEFINE_SYMBOL SOMELIB_MAKEDLL) + +generate_export_header(somelib) + +add_executable(consumer main.cpp) + +target_link_libraries(consumer somelib) diff --git a/Tests/Module/GenerateExportHeader/override_symbol/main.cpp b/Tests/Module/GenerateExportHeader/override_symbol/main.cpp new file mode 100644 index 0000000..445a652 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/override_symbol/main.cpp @@ -0,0 +1,9 @@ + +#include "someclass.h" + +int main(int, char**) +{ + SomeClass sc; + sc.someMethod(); + return 0; +}
\ No newline at end of file diff --git a/Tests/Module/GenerateExportHeader/override_symbol/someclass.cpp b/Tests/Module/GenerateExportHeader/override_symbol/someclass.cpp new file mode 100644 index 0000000..7326b78 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/override_symbol/someclass.cpp @@ -0,0 +1,7 @@ + +#include "someclass.h" + +void SomeClass::someMethod() const +{ + +}
\ No newline at end of file diff --git a/Tests/Module/GenerateExportHeader/override_symbol/someclass.h b/Tests/Module/GenerateExportHeader/override_symbol/someclass.h new file mode 100644 index 0000000..ae5e844 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/override_symbol/someclass.h @@ -0,0 +1,8 @@ + +#include "somelib_export.h" + +class SOMELIB_EXPORT SomeClass +{ +public: + void someMethod() const; +}; |