Skip to content

Commit e6c0ce1

Browse files
Fix library linking on Windows
Static libraries need a different name to avoid clash with DLL import library Import library now installed Add DLL export symbols file
1 parent cf5d913 commit e6c0ce1

4 files changed

Lines changed: 101 additions & 10 deletions

File tree

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,14 @@ add_custom_target(html)
5151
if(CMAKE_HOST_UNIX)
5252
#easy on Unix - just follow the GNU standard
5353
include(GNUInstallDirs)
54+
set(STATIC_LIBRARY_SUFFIX "")
5455
else()
5556
set(CMAKE_INSTALL_LIBDIR lib)
5657
set(CMAKE_INSTALL_DOCDIR doc)
5758
set(CMAKE_INSTALL_INCLUDEDIR include)
5859
set(CMAKE_INSTALL_MANDIR man)
5960
set(CMAKE_INSTALL_BINDIR bin)
61+
set(STATIC_LIBRARY_SUFFIX "Static")
6062
endif()
6163

6264

bindings/cpp/CMakeLists.txt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ set_property(SOURCE ${SOURCES} APPEND PROPERTY COMPILE_FLAGS ${NX_CFLAGS})
3838
#------------------------------------------------------------------------------
3939
add_library (NeXus_CPP_Static_Library STATIC ${HEADERS} ${SOURCES})
4040
set_target_properties(NeXus_CPP_Static_Library PROPERTIES
41-
OUTPUT_NAME NeXusCPP)
41+
OUTPUT_NAME NeXusCPP${STATIC_LIBRARY_SUFFIX})
4242

4343
target_link_libraries(NeXus_CPP_Static_Library NeXus_Static_Library)
4444

@@ -51,9 +51,13 @@ set_target_properties(NeXus_CPP_Shared_Library PROPERTIES
5151
VERSION "${ABI_VERSION}"
5252
SOVERSION ${ABI_CURRENT})
5353

54-
install (TARGETS NeXus_CPP_Static_Library NeXus_CPP_Shared_Library
54+
install (TARGETS NeXus_CPP_Shared_Library
55+
RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Runtime
56+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Development)
57+
58+
install (TARGETS NeXus_CPP_Static_Library
5559
DESTINATION ${CMAKE_INSTALL_LIBDIR}
56-
COMPONENT Runtime )
60+
COMPONENT Development)
5761

5862
INSTALL (FILES ${HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/nexus
5963
COMPONENT Development)

src/CMakeLists.txt

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,9 @@ endif (WIN32)
3737
# generate list of common source files
3838
#-----------------------------------------------------------------------------
3939
set (NAPISRC napi.c napiu.c nxstack.c nxstack.h stptok.c nxdataset.c
40+
napi_fortran_helper.c
4041
nxdataset.h nx_stptok.h)
4142

42-
if (ENABLE_FORTRAN90 OR ENABLE_FORTRAN77)
43-
set (NAPISRC ${NAPISRC} napi_fortran_helper.c)
44-
endif(ENABLE_FORTRAN90 OR ENABLE_FORTRAN77)
45-
4643
set (NAPILINK)
4744

4845
#-----------------------------------------------------------------------------
@@ -80,7 +77,7 @@ set_property(SOURCE ${NAPISRC} APPEND PROPERTY COMPILE_FLAGS ${NX_CFLAGS})
8077
add_library (NeXus_Static_Library STATIC ${NAPISRC})
8178

8279
set_target_properties(NeXus_Static_Library PROPERTIES
83-
OUTPUT_NAME NeXus)
80+
OUTPUT_NAME NeXus${STATIC_LIBRARY_SUFFIX})
8481

8582
target_link_libraries(NeXus_Static_Library ${NAPI_LINK_LIBS})
8683
#------------------------------------------------------------------------------
@@ -92,6 +89,10 @@ set_target_properties(NeXus_Shared_Library PROPERTIES
9289
OUTPUT_NAME NeXus
9390
VERSION ${ABI_VERSION}
9491
SOVERSION ${ABI_CURRENT})
92+
if(MSVC)
93+
set_target_properties(NeXus_Shared_Library PROPERTIES LINK_FLAGS
94+
"/DEF:\"${CMAKE_CURRENT_SOURCE_DIR}/NeXus.def\"")
95+
endif(MSVC)
9596

9697
target_link_libraries(NeXus_Shared_Library ${NAPI_LINK_LIBS})
9798

@@ -100,8 +101,8 @@ target_link_libraries(NeXus_Shared_Library ${NAPI_LINK_LIBS})
100101
# install the targets
101102
#-----------------------------------------------------------------------------
102103
install (TARGETS NeXus_Shared_Library
103-
DESTINATION ${CMAKE_INSTALL_LIBDIR}
104-
COMPONENT Runtime)
104+
RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Runtime
105+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Development)
105106

106107
install (TARGETS NeXus_Static_Library
107108
DESTINATION ${CMAKE_INSTALL_LIBDIR}

src/NeXus.def

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
LIBRARY NeXus.dll
2+
EXPORTS
3+
NXIReportError
4+
NXIprintlink
5+
NXMDisableErrorReporting
6+
NXMEnableErrorReporting
7+
NXMGetError
8+
NXMSetError
9+
NXMSetTError
10+
createNXDataset
11+
createTextNXDataset
12+
dropNXDataset
13+
getNXDatasetByteLength
14+
getNXDatasetDim
15+
getNXDatasetLength
16+
getNXDatasetRank
17+
getNXDatasetText
18+
getNXDatasetType
19+
getNXDatasetValue
20+
getNXDatasetValueAt
21+
nxiclose_
22+
nxiclosedata_
23+
nxiclosegroup_
24+
nxicompmakedata_
25+
nxicompmakedata64_
26+
nxicompress_
27+
nxifclose_
28+
nxifcompmakedata_
29+
nxifcompress_
30+
nxifflush_
31+
nxiflush_
32+
nxifmakedata_
33+
nxifopen_
34+
nxifputattr_
35+
nxifree_
36+
nxigetattr_
37+
nxigetattrinfo_
38+
nxigetdata_
39+
nxigetdataid_
40+
nxigetgroupid_
41+
nxigetgroupinfo_
42+
nxigetrawinfo_
43+
nxigetrawinfo64_
44+
nxigetinfo_
45+
nxigetinfo64_
46+
nxigetnextattr_
47+
nxigetnextentry_
48+
nxigetslab_
49+
nxigetslab64_
50+
nxiinitattrdir_
51+
nxiinitgroupdir_
52+
nxiinquirefile_
53+
nxiisexternalgroup_
54+
nxilinkexternal_
55+
nximakedata_
56+
nximakedata64_
57+
nximakegroup_
58+
nximakelink_
59+
nximakenamedlink_
60+
nximalloc_
61+
nximalloc64_
62+
nxiopen_
63+
nxiopendata_
64+
nxiopengroup_
65+
nxiopengrouppath_
66+
nxiopenpath_
67+
nxiopensourcegroup_
68+
nxiputattr_
69+
nxiputdata_
70+
nxiputslab_
71+
nxiputslab64_
72+
nxisameid_
73+
nxisetcache_
74+
nxisetnumberformat_
75+
putNXDatasetValue
76+
putNXDatasetValueAt
77+
nxigetpath_
78+
nxilinkexternaldataset_
79+
nxiisexternaldataset_
80+
nxireopen_
81+
nxiputattra_
82+
nxigetnextattra_
83+
nxigetattra_
84+
nxigetattrainfo_

0 commit comments

Comments
 (0)