Skip to content

Commit d69492e

Browse files
committed
Creating per-library EXPORT symbols
Signed-off-by: Andrew V. Jones <[email protected]>
1 parent b2f7606 commit d69492e

File tree

8 files changed

+29
-12
lines changed

8 files changed

+29
-12
lines changed

C/API.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
// From https://gcc.gnu.org/wiki/Visibility
2525
#if defined _WIN32 || defined __CYGWIN__
26-
#ifdef EXPORT_API
26+
#ifdef EXPORT_C_API
2727
#ifdef __GNUC__
2828
#define PSY_C_API __attribute__ ((dllexport))
2929
#else

C/CMakeLists.txt

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,20 @@ set(CFE_CXX_FLAGS "${CFE_CXX_FLAGS} -g")
1515
set(CFE_CXX_FLAGS "${CFE_CXX_FLAGS} -Wall \
1616
-Wsign-compare")
1717

18+
# Must happen before adding EXPORT_C_API to CFE_CXX_FLAGS
19+
set(CFE_CXX_FLAGS "${CFE_CXX_FLAGS} -DEXPORT_C_API")
20+
set(PLUGIN_CXX_FLAGS "${CFE_CXX_FLAGS} -DEXPORT_PLUGIN_API")
21+
1822
set(CMAKE_MACOSX_RPATH TRUE)
1923

24+
set(PLUGIN_SOURCES
25+
# Plugin API files
26+
${PROJECT_SOURCE_DIR}/plugin-api/PluginConfig.h
27+
${PROJECT_SOURCE_DIR}/plugin-api/DeclarationInterceptor.h
28+
${PROJECT_SOURCE_DIR}/plugin-api/SourceInspector.h
29+
${PROJECT_SOURCE_DIR}/plugin-api/VisitorObserver.h
30+
)
31+
2032
set(CFE_SOURCES
2133
# Main
2234
${PROJECT_SOURCE_DIR}/API.h
@@ -103,12 +115,6 @@ set(CFE_SOURCES
103115
${PROJECT_SOURCE_DIR}/names/DeclarationName.h
104116
${PROJECT_SOURCE_DIR}/names/DeclarationNames.cpp
105117
${PROJECT_SOURCE_DIR}/names/DeclarationNames.h
106-
107-
# Plugin API files
108-
${PROJECT_SOURCE_DIR}/plugin-api/PluginConfig.h
109-
${PROJECT_SOURCE_DIR}/plugin-api/DeclarationInterceptor.h
110-
${PROJECT_SOURCE_DIR}/plugin-api/SourceInspector.h
111-
${PROJECT_SOURCE_DIR}/plugin-api/VisitorObserver.h
112118

113119
# Tests
114120
${PROJECT_SOURCE_DIR}/tests/TestBinder.h
@@ -125,6 +131,13 @@ set(CFE_SOURCES
125131
${PROJECT_SOURCE_DIR}/tests/TestTypeChecker.cpp
126132
)
127133

134+
foreach(file ${PLUGIN_SOURCES})
135+
set_source_files_properties(
136+
${file} PROPERTIES
137+
COMPILE_FLAGS "${PLUGIN_CXX_FLAGS}"
138+
)
139+
endforeach()
140+
128141
foreach(file ${CFE_SOURCES})
129142
set_source_files_properties(
130143
${file} PROPERTIES
@@ -138,7 +151,7 @@ include_directories(
138151
)
139152

140153
set(LIBRARY psychecfe)
141-
add_library(${LIBRARY} SHARED ${CFE_SOURCES})
154+
add_library(${LIBRARY} SHARED ${CFE_SOURCES} ${PLUGIN_SOURCES})
142155

143156
target_link_libraries(${LIBRARY} psychecommon)
144157

C/plugin-api/PluginConfig.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
// From https://gcc.gnu.org/wiki/Visibility
2525
#if defined _WIN32 || defined __CYGWIN__
26-
#ifdef EXPORT_API
26+
#ifdef EXPORT_PLUGIN_API
2727
#ifdef __GNUC__
2828
#define PLUGIN_API __attribute__ ((dllexport))
2929
#else

C/stdlib-support/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ set(STD_CXX_FLAGS "${STD_CXX_FLAGS} -g")
1212
set(STD_CXX_FLAGS "${STD_CXX_FLAGS} -Wall \
1313
-Wsign-compare")
1414

15+
set(STD_CXX_FLAGS "${STD_CXX_FLAGS} -DEXPORT_C_API -DEXPORT_PLUGIN_API")
16+
1517
set(CMAKE_MACOSX_RPATH TRUE)
1618
set(CMAKE_INSTALL_RPATH "\$ORIGIN;@executable_path;@loader_path")
1719

common/API.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
// From https://gcc.gnu.org/wiki/Visibility
2525
#if defined _WIN32 || defined __CYGWIN__
26-
#ifdef EXPORT_API
26+
#ifdef EXPORT_PSY_API
2727
#ifdef __GNUC__
2828
#define PSY_API __attribute__ ((dllexport))
2929
#else

common/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ set(COMMON_CXX_FLAGS)
1111
set(COMMON_CXX_FLAGS "${CFE_CXX_FLAGS} -g")
1212
set(COMMON_CXX_FLAGS "${CFE_CXX_FLAGS} -Wall \
1313
-Wsign-compare")
14+
set(COMMON_CXX_FLAGS "${CFE_CXX_FLAGS} -DEXPORT_PSY_API")
15+
1416

1517
set(CMAKE_MACOSX_RPATH TRUE)
1618

common/diagnostics/Diagnostic.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class PSY_API Diagnostic
8080
friend class C::TestFrontend;
8181
};
8282

83-
std::ostream& operator<<(std::ostream& os, const Diagnostic& diagnostic);
83+
PSY_API std::ostream& operator<<(std::ostream& os, const Diagnostic& diagnostic);
8484

8585
} // psy
8686

common/location/LinePosition.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ bool operator==(const LinePosition& a, const LinePosition& b);
5858

5959
bool operator<(const LinePosition& a, const LinePosition& b);
6060

61-
std::ostream& operator<<(std::ostream& os, const LinePosition& pos);
61+
PSY_API std::ostream& operator<<(std::ostream& os, const LinePosition& pos);
6262

6363
} // psy
6464

0 commit comments

Comments
 (0)