build: windows: enable automatic imports by default
authorAlexey Sheplyakov <asheplyakov@altlinux.org>
Thu, 26 Dec 2019 17:45:11 +0000 (21:45 +0400)
committerAlexey Sheplyakov <asheplyakov@altlinux.org>
Fri, 28 Aug 2020 15:15:31 +0000 (19:15 +0400)
For now there are no dllexport/dllimport markings in GiNaC and CLN, so
export all symbols when building GiNaC DLL, and enable automatic imports
when linking with it. Note: this works with GNU linker only.

ginac/CMakeLists.txt

index 07d8530ecae6b3a7ca1a08f0e98d022a6737cbab..98bd89b80fec372b4518480cff0dc19a9b8b9145 100644 (file)
@@ -154,6 +154,12 @@ set_target_properties(ginac PROPERTIES
 target_link_libraries(ginac ${CLN_LIBRARIES})
 include_directories(${CMAKE_SOURCE_DIR}/ginac)
 
+if (WIN32 AND CMAKE_COMPILER_IS_GNUCXX AND BUILD_SHARED_LIBS)
+       set_target_properties(ginac PROPERTIES
+               LINK_FLAGS "-Wl,--enable-auto-import -Wl,--export-all-symbols"
+       )
+endif()
+
 if (NOT BUILD_SHARED_LIBS)
        set_target_properties(ginac PROPERTIES OUTPUT_NAME "ginac")
        # Avoid the static library vs import library conflict (necessary for