Skip to content

Commit 660a43e

Browse files
committed
Generate export macros in a separate file.
1 parent ec9c468 commit 660a43e

3 files changed

Lines changed: 28 additions & 36 deletions

File tree

bindings/cpp/CMakeLists.txt

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,74 @@
11
## Process this file with cmake
22
#==============================================================================
33
# NeXus - Neutron & X-ray Common Data Format
4-
#
4+
#
55
# CMakeLists for building the NeXus library and applications.
66
#
77
# Copyright (C) 2011 Stephen Rankin
8-
#
8+
#
99
# This library is free software; you can redistribute it and/or modify it under
1010
# the terms of the GNU Lesser General Public License as published by the Free
1111
# Software Foundation; either version 2 of the License, or (at your option) any
1212
# later version.
13-
#
13+
#
1414
# This library is distributed in the hope that it will be useful, but WITHOUT
1515
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
1616
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
1717
# details.
18-
#
18+
#
1919
# You should have received a copy of the GNU Lesser General Public License
2020
# along with this library; if not, write to the Free Software Foundation, Inc.,
2121
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22-
#
22+
#
2323
# For further information, see <http://www.nexusformat.org>
2424
#
2525
#
2626
#==============================================================================
2727

28-
add_definitions(-DIN_NEXUS_CPP_LIBRARY=1 ${NX_CPP})
29-
28+
include(GenerateExportHeader)
3029
#Make NeXus CPP Bindings Static Library
3130

3231
set (HEADERS NeXusFile.hpp NeXusException.hpp NeXusStream.hpp)
33-
set (SOURCES NeXusFile.hpp NeXusFile.cpp NeXusException.hpp
32+
set (SOURCES NeXusFile.hpp NeXusFile.cpp NeXusException.hpp
3433
NeXusException.cpp NeXusStream.hpp NeXusStream.cpp)
3534

3635
set_property(SOURCE ${SOURCES} APPEND PROPERTY COMPILE_FLAGS ${NX_CFLAGS})
3736

38-
#------------------------------------------------------------------------------
39-
add_library (NeXus_CPP_Static_Library STATIC ${HEADERS} ${SOURCES})
40-
set_target_properties(NeXus_CPP_Static_Library PROPERTIES
41-
OUTPUT_NAME NeXusCPP${STATIC_LIBRARY_SUFFIX})
42-
43-
target_link_libraries(NeXus_CPP_Static_Library NeXus_Static_Library)
44-
4537
#Make NeXus CPP Bindings Shared Library
4638
#------------------------------------------------------------------------------
4739
add_library (NeXus_CPP_Shared_Library SHARED ${HEADERS} ${SOURCES})
4840
target_link_libraries(NeXus_CPP_Shared_Library NeXus_Shared_Library)
41+
target_include_directories(NeXus_CPP_Shared_Library PUBLIC ${CMAKE_CURRENT_BINARY_DIR} )
4942
set_target_properties(NeXus_CPP_Shared_Library PROPERTIES
5043
OUTPUT_NAME NeXusCPP
5144
VERSION "${ABI_VERSION}"
5245
SOVERSION ${ABI_CURRENT})
5346

47+
generate_export_header(NeXus_CPP_Shared_Library
48+
BASE_NAME NEXUS_CPP
49+
EXPORT_FILE_NAME NeXusExport.hpp
50+
EXPORT_MACRO_NAME NXDLL_EXPORT)
51+
52+
#------------------------------------------------------------------------------
53+
add_library (NeXus_CPP_Static_Library STATIC ${HEADERS} ${SOURCES})
54+
set_target_properties(NeXus_CPP_Static_Library PROPERTIES
55+
OUTPUT_NAME NeXusCPP${STATIC_LIBRARY_SUFFIX}
56+
COMPILE_FLAGS -DNEXUS_CPP_STATIC_DEFINE)
57+
target_include_directories(NeXus_CPP_Static_Library PUBLIC ${CMAKE_CURRENT_BINARY_DIR} )
58+
target_link_libraries(NeXus_CPP_Static_Library NeXus_Static_Library)
59+
60+
61+
#------------------------------------------------------------------------------
62+
5463
install (TARGETS NeXus_CPP_Shared_Library
5564
RUNTIME DESTINATION ${NEXUS_INSTALL_SHLIB} COMPONENT Runtime
5665
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Development
5766
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Development)
5867

59-
install (TARGETS NeXus_CPP_Static_Library
68+
install (TARGETS NeXus_CPP_Static_Library
6069
DESTINATION ${CMAKE_INSTALL_LIBDIR}
6170
COMPONENT Development)
6271

63-
INSTALL (FILES ${HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/nexus
72+
INSTALL (FILES ${HEADERS} ${CMAKE_CURRENT_BINARY_DIR}/NeXusExport.hpp DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/nexus
6473
COMPONENT Development)
6574

66-
67-
68-

bindings/cpp/NeXusException.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include <string>
55
#include <stdexcept>
6+
#include "NeXusExport.hpp"
67

78
/**
89
* \file NeXusException.hpp

bindings/cpp/NeXusFile.hpp

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,7 @@
66
#include <utility>
77
#include <vector>
88
#include "napi.h"
9-
10-
#ifdef _WIN32
11-
12-
#ifndef _MSC_VER
13-
# define NXDLL_EXPORT
14-
#else
15-
# if IN_NEXUS_CPP_LIBRARY
16-
# define NXDLL_EXPORT __declspec(dllexport)
17-
# else
18-
# define NXDLL_EXPORT __declspec(dllimport)
19-
# endif
20-
#endif /* _MSC_VER */
21-
22-
#else /* _WIN32 */
23-
# define NXDLL_EXPORT
24-
#endif /* _WIN32 */
9+
#include "NeXusExport.hpp"
2510

2611
/**
2712
* \file NeXusFile.hpp Definition of the NeXus C++ API.

0 commit comments

Comments
 (0)