Skip to content

Commit dfd7fd2

Browse files
committed
Fix visibility header
1 parent d9dd6a6 commit dfd7fd2

File tree

17 files changed

+76
-136
lines changed

17 files changed

+76
-136
lines changed

.magnum.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ before_install:
1717
- gfortran --version
1818
- python --version
1919
script:
20-
- python setup.py --cxx=g++ --cc=gcc --fc=gfortran --type=debug --cmake-options='-Hprojects/CMake -DENABLE_FORTRAN_API=ON'
20+
- python setup.py --cxx=g++ --cc=gcc --fc=gfortran --type=debug --cmake-options='-Hprojects/CMake'
2121
- cd build
2222
- VERBOSE=1 make
2323
- ctest -V

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,9 @@ before_script:
235235
- python --version
236236
- |
237237
if [[ "${COVERAGE}" = true ]]; then
238-
python setup.py --cxx=${CXX_COMPILER} --cc=${C_COMPILER} --fc=${Fortran_COMPILER} --type=${BUILD_TYPE} --cmake-options='-Hprojects/CMake -DENABLE_FORTRAN_API=ON' --coverage
238+
python setup.py --cxx=${CXX_COMPILER} --cc=${C_COMPILER} --fc=${Fortran_COMPILER} --type=${BUILD_TYPE} --cmake-options='-Hprojects/CMake' --coverage
239239
else
240-
python setup.py --cxx=${CXX_COMPILER} --cc=${C_COMPILER} --fc=${Fortran_COMPILER} --type=${BUILD_TYPE} --cmake-options='-Hprojects/CMake -DENABLE_FORTRAN_API=ON'
240+
python setup.py --cxx=${CXX_COMPILER} --cc=${C_COMPILER} --fc=${Fortran_COMPILER} --type=${BUILD_TYPE} --cmake-options='-Hprojects/CMake'
241241
fi
242242
- cd build
243243
script:

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ include(autocmake_omp)
4040
include(autocmake_safeguards)
4141
include(autocmake_python_interpreter)
4242
include(pcmsolver)
43+
include(api)
4344
include(autocmake_git_info)
4445
include(autocmake_boost)
4546
include(version)
@@ -51,7 +52,6 @@ include(zlib)
5152
include(autogenerated)
5253
include(documentation)
5354
include(export)
54-
include(api)
5555
include(autocmake_src)
5656
include(test)
5757
include(summary)

api/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
install(FILES ${PROJECT_SOURCE_DIR}/api/pcmsolver.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME})
2+
install(FILES ${PROJECT_SOURCE_DIR}/api/PCMInput.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME})
3+
4+
if(ENABLE_FORTRAN_API)
5+
add_library(fortran_bindings OBJECT ${PROJECT_SOURCE_DIR}/api/pcmsolver.f90)
6+
list(APPEND _objects $<TARGET_OBJECTS:fortran_bindings>)
7+
endif()

api/pcmsolver.h

Lines changed: 22 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,9 @@
2626

2727
#include <stddef.h>
2828
#include "PCMInput.h"
29+
#include "PCMSolverExport.h"
2930

30-
#ifndef PCMSOLVER_API
31-
#ifdef _WIN32
32-
#if defined(PCMSOLVER_BUILD_SHARED) /* build dll */
33-
#define PCMSOLVER_API __declspec(dllexport)
34-
#elif !defined(PCMSOLVER_BUILD_STATIC) /* use dll */
35-
#define PCMSOLVER_API __declspec(dllimport)
36-
#else /* static library */
37-
#define PCMSOLVER_API
38-
#endif
39-
#else
40-
#if __GNUC__ >= 4
41-
#define PCMSOLVER_API __attribute__((visibility("default")))
42-
#else
43-
#define PCMSOLVER_API
44-
#endif
45-
#endif
46-
#endif
31+
#define PCMSolver_API PCMSolver_EXPORT
4732

4833
// To cope with the fact that C doesn't have bool as primitive type
4934
#ifndef pcmsolver_bool_t_DEFINED
@@ -108,7 +93,7 @@ typedef void (*HostWriter)(const char * message);
10893
* of 4 integers: number of generators, first, second and third generator
10994
* respectively. Generators map to integers as in table :ref:`symmetry-ops`
11095
*/
111-
PCMSOLVER_API pcmsolver_context_t * pcmsolver_new(pcmsolver_reader_t input_reading,
96+
PCMSolver_API pcmsolver_context_t * pcmsolver_new(pcmsolver_reader_t input_reading,
11297
int nr_nuclei, double charges[],
11398
double coordinates[],
11499
int symmetry_info[],
@@ -118,56 +103,56 @@ PCMSOLVER_API pcmsolver_context_t * pcmsolver_new(pcmsolver_reader_t input_readi
118103
/*! \brief Deletes a PCM context object
119104
* \param[in, out] context the PCM context object to be deleted
120105
*/
121-
PCMSOLVER_API void pcmsolver_delete(pcmsolver_context_t * context);
106+
PCMSolver_API void pcmsolver_delete(pcmsolver_context_t * context);
122107

123108
/*! \brief Whether the library is compatible with the header file
124109
* Checks that the compiled library and header file version match.
125110
* Host should abort when that is not the case.
126111
* \warning This function should be called **before** instantiating
127112
* any PCM context objects.
128113
*/
129-
PCMSOLVER_API pcmsolver_bool_t pcmsolver_is_compatible_library(void);
114+
PCMSolver_API pcmsolver_bool_t pcmsolver_is_compatible_library(void);
130115

131116
/*! \brief Prints citation and set up information
132117
* \param[in, out] context the PCM context object
133118
*/
134-
PCMSOLVER_API void pcmsolver_print(pcmsolver_context_t * context);
119+
PCMSolver_API void pcmsolver_print(pcmsolver_context_t * context);
135120

136121
/*! \brief Getter for the number of finite elements composing the molecular cavity
137122
* \param[in, out] context the PCM context object
138123
* \return the size of the cavity
139124
*/
140-
PCMSOLVER_API int pcmsolver_get_cavity_size(pcmsolver_context_t * context);
125+
PCMSolver_API int pcmsolver_get_cavity_size(pcmsolver_context_t * context);
141126

142127
/*! \brief Getter for the number of irreducible finite elements composing the
143128
* molecular cavity
144129
* \param[in, out] context the PCM context object
145130
* \return the number of irreducible finite elements
146131
*/
147-
PCMSOLVER_API int pcmsolver_get_irreducible_cavity_size(
132+
PCMSolver_API int pcmsolver_get_irreducible_cavity_size(
148133
pcmsolver_context_t * context);
149134

150135
/*! \brief Getter for the centers of the finite elements composing the molecular
151136
* cavity
152137
* \param[in, out] context the PCM context object
153138
* \param[out] centers array holding the coordinates of the finite elements centers
154139
*/
155-
PCMSOLVER_API void pcmsolver_get_centers(pcmsolver_context_t * context,
140+
PCMSolver_API void pcmsolver_get_centers(pcmsolver_context_t * context,
156141
double centers[]);
157142

158143
/*! \brief Getter for the center of the i-th finite element
159144
* \param[in, out] context the PCM context object
160145
* \param[in] its index of the finite element
161146
* \param[out] center array holding the coordinates of the finite element center
162147
*/
163-
PCMSOLVER_API void pcmsolver_get_center(pcmsolver_context_t * context, int its,
148+
PCMSolver_API void pcmsolver_get_center(pcmsolver_context_t * context, int its,
164149
double center[]);
165150

166151
/*! \brief Getter for the areas/weights of the finite elements
167152
* \param[in, out] context the PCM context object
168153
* \param[out] areas array holding the weights/areas of the finite elements
169154
*/
170-
PCMSOLVER_API void pcmsolver_get_areas(pcmsolver_context_t * context,
155+
PCMSolver_API void pcmsolver_get_areas(pcmsolver_context_t * context,
171156
double areas[]);
172157

173158
/*! \brief Computes ASC given a MEP and the desired irreducible representation
@@ -179,7 +164,7 @@ PCMSOLVER_API void pcmsolver_get_areas(pcmsolver_context_t * context,
179164
* and charges. Given labels for each, this function retrieves the MEP
180165
* and computes the corresponding ASC.
181166
*/
182-
PCMSOLVER_API void pcmsolver_compute_asc(pcmsolver_context_t * context,
167+
PCMSolver_API void pcmsolver_compute_asc(pcmsolver_context_t * context,
183168
const char * mep_name,
184169
const char * asc_name, int irrep);
185170

@@ -194,7 +179,7 @@ PCMSOLVER_API void pcmsolver_compute_asc(pcmsolver_context_t * context,
194179
* permittivity
195180
* otherwise.
196181
*/
197-
PCMSOLVER_API void pcmsolver_compute_response_asc(pcmsolver_context_t * context,
182+
PCMSolver_API void pcmsolver_compute_response_asc(pcmsolver_context_t * context,
198183
const char * mep_name,
199184
const char * asc_name, int irrep);
200185

@@ -205,7 +190,7 @@ PCMSOLVER_API void pcmsolver_compute_response_asc(pcmsolver_context_t * context,
205190
* \return the polarization energy
206191
* This function calculates the dot product of the given MEP and ASC vectors.
207192
*/
208-
PCMSOLVER_API double pcmsolver_compute_polarization_energy(
193+
PCMSolver_API double pcmsolver_compute_polarization_energy(
209194
pcmsolver_context_t * context, const char * mep_name, const char * asc_name);
210195

211196
/*! \brief Getter for the ASC dipole
@@ -214,7 +199,7 @@ PCMSOLVER_API double pcmsolver_compute_polarization_energy(
214199
* \param[out] dipole the Cartesian components of the ASC dipole moment
215200
* \return the ASC dipole, i.e. \sqrt{\sum_i \mu_i^2}
216201
*/
217-
PCMSOLVER_API double pcmsolver_get_asc_dipole(pcmsolver_context_t * context,
202+
PCMSolver_API double pcmsolver_get_asc_dipole(pcmsolver_context_t * context,
218203
const char * asc_name,
219204
double dipole[]);
220205

@@ -224,7 +209,7 @@ PCMSOLVER_API double pcmsolver_get_asc_dipole(pcmsolver_context_t * context,
224209
* \param[in] values the values wrapped in the surface function
225210
* \param[in] name label of the surface function
226211
*/
227-
PCMSOLVER_API void pcmsolver_get_surface_function(pcmsolver_context_t * context,
212+
PCMSolver_API void pcmsolver_get_surface_function(pcmsolver_context_t * context,
228213
int size, double values[],
229214
const char * name);
230215

@@ -234,40 +219,40 @@ PCMSOLVER_API void pcmsolver_get_surface_function(pcmsolver_context_t * context,
234219
* \param[in] values the values to be wrapped in the surface function
235220
* \param[in] name label of the surface function
236221
*/
237-
PCMSOLVER_API void pcmsolver_set_surface_function(pcmsolver_context_t * context,
222+
PCMSolver_API void pcmsolver_set_surface_function(pcmsolver_context_t * context,
238223
int size, double values[],
239224
const char * name);
240225

241226
/*! \brief Prints surface function contents to host output
242227
* \param[in, out] context the PCM context object
243228
* \param[in] name label of the surface function
244229
*/
245-
PCMSOLVER_API void pcmsolver_print_surface_function(pcmsolver_context_t * context,
230+
PCMSolver_API void pcmsolver_print_surface_function(pcmsolver_context_t * context,
246231
const char * name);
247232

248233
/*! \brief Dumps all currently saved surface functions to NumPy arrays in .npy files
249234
* \param[in, out] context the PCM context object
250235
*/
251-
PCMSOLVER_API void pcmsolver_save_surface_functions(pcmsolver_context_t * context);
236+
PCMSolver_API void pcmsolver_save_surface_functions(pcmsolver_context_t * context);
252237

253238
/*! \brief Dumps a surface function to NumPy array in .npy file
254239
* \param[in, out] context the PCM context object
255240
* \param[in] name label of the surface function
256241
*/
257-
PCMSOLVER_API void pcmsolver_save_surface_function(pcmsolver_context_t * context,
242+
PCMSolver_API void pcmsolver_save_surface_function(pcmsolver_context_t * context,
258243
const char * name);
259244

260245
/*! \brief Loads a surface function from a .npy file
261246
* \param[in, out] context the PCM context object
262247
* \param[in] name label of the surface function
263248
*/
264-
PCMSOLVER_API void pcmsolver_load_surface_function(pcmsolver_context_t * context,
249+
PCMSolver_API void pcmsolver_load_surface_function(pcmsolver_context_t * context,
265250
const char * name);
266251

267252
/*! \brief Writes timing results for the API
268253
* \param[in, out] context the PCM context object
269254
*/
270-
PCMSOLVER_API void pcmsolver_write_timings(pcmsolver_context_t * context);
255+
PCMSolver_API void pcmsolver_write_timings(pcmsolver_context_t * context);
271256

272257
#ifdef __cplusplus
273258
}

cmake/autocmake.cfg

Lines changed: 0 additions & 67 deletions
This file was deleted.

cmake/autocmake.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ modules:
2929
- '%(url_root)modules/safeguards.cmake'
3030
- '%(url_root)modules/python_interpreter.cmake'
3131
- 'custom/pcmsolver.cmake'
32+
- 'custom/api.cmake'
3233
- '%(url_root)modules/git_info/git_info.cmake'
3334
- boost:
3435
- major: 1
@@ -46,7 +47,6 @@ modules:
4647
- 'custom/autogenerated.cmake'
4748
- 'custom/documentation.cmake'
4849
- 'custom/export.cmake'
49-
- 'custom/api.cmake'
5050
- src:
5151
- source: '%(url_root)modules/src.cmake'
5252
- custom:

cmake/custom/api.cmake

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,7 @@
1212
# docopt: "--fbindings=<ENABLE_FORTRAN_API> Enable compilation of Fortran 90 API bindings <ON/OFF> [default: ON]."
1313
# define: "'-DENABLE_FORTRAN_API={0}'.format(arguments['--fbindings'])"
1414

15-
include_directories(${PROJECT_SOURCE_DIR}/api)
16-
17-
install(FILES ${PROJECT_SOURCE_DIR}/api/pcmsolver.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME})
18-
install(FILES ${PROJECT_SOURCE_DIR}/api/PCMInput.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME})
15+
option(ENABLE_FORTRAN_API "Enable compilation of Fortran 90 API bindings" ON)
1916

20-
if(ENABLE_FORTRAN_API)
21-
add_definitions(-DENABLE_FORTRAN_API)
22-
add_library(fortran_bindings OBJECT ${PROJECT_SOURCE_DIR}/api/pcmsolver.f90)
23-
list(APPEND _objects $<TARGET_OBJECTS:fortran_bindings>)
24-
endif()
17+
add_subdirectory(api)
18+
include_directories(${PROJECT_SOURCE_DIR}/api)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
option(ENABLE_CXX11_SUPPORT "Enable C++11 compiler support" ON)
22

3+
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
4+
set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
5+
36
include(GNU.CXX)
47
include(Clang.CXX)
58
include(Intel.CXX)

cmake/custom/pcmsolver.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
option(ENABLE_LOGGER "Enable logger" OFF)
22
option(ENABLE_TIMER "Enable timer" ON)
33
option(BUILD_STANDALONE "Enable build of standalone executables" ON)
4-
option(ENABLE_FORTRAN_API "Builds optional Fortran90 API" OFF)
54

65
# Add definitions
76
if(ENABLE_TIMER)

0 commit comments

Comments
 (0)