| Summary: | Windows DLLs are not built under CMake | ||
|---|---|---|---|
| Product: | Geant4 | Reporter: | Ben Morgan <Ben.Morgan> |
| Component: | cmake | Assignee: | Ben Morgan <Ben.Morgan> |
| Status: | CLOSED FIXED | ||
| Severity: | major | ||
| Priority: | P2 | ||
| Version: | 9.4 | ||
| Hardware: | PC | ||
| OS: | Windows | ||
|
Description
Ben Morgan
2011-04-21 15:39:27 CEST
On item b), there are two sets of definitions to be handled: 1) G4LIB_BUILD_DLL : this must be used globally if we want to build DLLs. It is directly used by the source files geant4/source/global/management/include/G4Types.hh geant4/source/geometry/volumes/include/G4NavigationHistory.hh geant4/source/geometry/volumes/src/G4NavigationHistory.cc and consequently any other files that #include those. G4Types.hh is the key file because this will define the needed export/import symbols for us if: i) WIN32 is defined, and ii) G4LIB_BUILD_DLL is defined. However, my understanding is that __declspec should only be used for DLLs. Because we offer the option to build both static and dynamic libraries, this should only be used for DLLs. That means adding a target level COMPILE_DEFINITIONS vis set_target_properties, so this can go in Geant4MacroLibraryTargets.cmake. 2) XXX_EXPORTS : these are generally defined at the category level and used to correctly define externs with import/export as needed. They are always needed, on all platforms and independent of whether DLLs are built or not, when Geant4 itself is built. Because they have many different names, but are at least category based, it's easiest to set them as an add_definitions command in the category level CMakeLists.txt. XXX_EXPORTS added to: global (G4IOS_ALLOC_EXPORT), tag: global-V09-04-08 geometry (G4GEOM_ALLOC_EXPORT), tag: geometry-V09-04-00 All XXX_EXPORTS now added to trunk, plus tagged as: global (G4IOS_ALLOC_EXPORT), tag: global-V09-04-08 geometry (G4GEOM_ALLOC_EXPORT), tag: geometry-V09-04-00 particles (G4PARTICLES_ALLOC_EXPORT), tag: particles-V09-04-05 track (G4TRACK_ALLOC_EXPORT), tag: track-V09-04-03 digits_hits (G4DIGI_ALLOC_EXPORT), tag: digits_hits-V09-04-05 tracking (G4TRACKING_ALLOC_EXPORT), tag: tracking-V09-04-01 event (G4EVENT_ALLOC_EXPORT), tag: event-V09-04-01 run (G4RUN_ALLOC_EXPORT), tag: run-V09-04-06 raytracer (G4VIS_ALLOC_EXPORT), tag: raytracer-V09-04-02 CMake category updated with: 1) New genwindef app (courtesy of Pere Mato Vila) to generate exported symbol definition file from an archive library. 2) New functionality in Geant4MacroLibraryTargets.cmake to use genwindef plus an existing or temporary archive library to generate the .def export file and build a DLL from this plus a dummy cpp file. Tested on Windows 7 with Visual Studio 2010 Express. Committed to SVN with tag: cmake-V09-04-01 Tag proposed on database, will mark as RESOLVED FIXED once tag is accepted. |