Skip to content

Commit

Permalink
Creating per-library EXPORT symbols (#44)
Browse files Browse the repository at this point in the history
* Creating per-library EXPORT symbols

Signed-off-by: Andrew V. Jones <[email protected]>

* Removing out of date comment

Signed-off-by: Andrew V. Jones <[email protected]>
  • Loading branch information
aytey authored Sep 24, 2021
1 parent b2f7606 commit 85f39b1
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 12 deletions.
2 changes: 1 addition & 1 deletion C/API.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

// From https://gcc.gnu.org/wiki/Visibility
#if defined _WIN32 || defined __CYGWIN__
#ifdef EXPORT_API
#ifdef EXPORT_C_API
#ifdef __GNUC__
#define PSY_C_API __attribute__ ((dllexport))
#else
Expand Down
26 changes: 19 additions & 7 deletions C/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,19 @@ set(CFE_CXX_FLAGS "${CFE_CXX_FLAGS} -g")
set(CFE_CXX_FLAGS "${CFE_CXX_FLAGS} -Wall \
-Wsign-compare")

set(CFE_CXX_FLAGS "${CFE_CXX_FLAGS} -DEXPORT_C_API")
set(PLUGIN_CXX_FLAGS "${CFE_CXX_FLAGS} -DEXPORT_PLUGIN_API")

set(CMAKE_MACOSX_RPATH TRUE)

set(PLUGIN_SOURCES
# Plugin API files
${PROJECT_SOURCE_DIR}/plugin-api/PluginConfig.h
${PROJECT_SOURCE_DIR}/plugin-api/DeclarationInterceptor.h
${PROJECT_SOURCE_DIR}/plugin-api/SourceInspector.h
${PROJECT_SOURCE_DIR}/plugin-api/VisitorObserver.h
)

set(CFE_SOURCES
# Main
${PROJECT_SOURCE_DIR}/API.h
Expand Down Expand Up @@ -103,12 +114,6 @@ set(CFE_SOURCES
${PROJECT_SOURCE_DIR}/names/DeclarationName.h
${PROJECT_SOURCE_DIR}/names/DeclarationNames.cpp
${PROJECT_SOURCE_DIR}/names/DeclarationNames.h

# Plugin API files
${PROJECT_SOURCE_DIR}/plugin-api/PluginConfig.h
${PROJECT_SOURCE_DIR}/plugin-api/DeclarationInterceptor.h
${PROJECT_SOURCE_DIR}/plugin-api/SourceInspector.h
${PROJECT_SOURCE_DIR}/plugin-api/VisitorObserver.h

# Tests
${PROJECT_SOURCE_DIR}/tests/TestBinder.h
Expand All @@ -125,6 +130,13 @@ set(CFE_SOURCES
${PROJECT_SOURCE_DIR}/tests/TestTypeChecker.cpp
)

foreach(file ${PLUGIN_SOURCES})
set_source_files_properties(
${file} PROPERTIES
COMPILE_FLAGS "${PLUGIN_CXX_FLAGS}"
)
endforeach()

foreach(file ${CFE_SOURCES})
set_source_files_properties(
${file} PROPERTIES
Expand All @@ -138,7 +150,7 @@ include_directories(
)

set(LIBRARY psychecfe)
add_library(${LIBRARY} SHARED ${CFE_SOURCES})
add_library(${LIBRARY} SHARED ${CFE_SOURCES} ${PLUGIN_SOURCES})

target_link_libraries(${LIBRARY} psychecommon)

Expand Down
2 changes: 1 addition & 1 deletion C/plugin-api/PluginConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

// From https://gcc.gnu.org/wiki/Visibility
#if defined _WIN32 || defined __CYGWIN__
#ifdef EXPORT_API
#ifdef EXPORT_PLUGIN_API
#ifdef __GNUC__
#define PLUGIN_API __attribute__ ((dllexport))
#else
Expand Down
2 changes: 2 additions & 0 deletions C/stdlib-support/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ set(STD_CXX_FLAGS "${STD_CXX_FLAGS} -g")
set(STD_CXX_FLAGS "${STD_CXX_FLAGS} -Wall \
-Wsign-compare")

set(STD_CXX_FLAGS "${STD_CXX_FLAGS} -DEXPORT_C_API -DEXPORT_PLUGIN_API")

set(CMAKE_MACOSX_RPATH TRUE)
set(CMAKE_INSTALL_RPATH "\$ORIGIN;@executable_path;@loader_path")

Expand Down
2 changes: 1 addition & 1 deletion common/API.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

// From https://gcc.gnu.org/wiki/Visibility
#if defined _WIN32 || defined __CYGWIN__
#ifdef EXPORT_API
#ifdef EXPORT_PSY_API
#ifdef __GNUC__
#define PSY_API __attribute__ ((dllexport))
#else
Expand Down
2 changes: 2 additions & 0 deletions common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ set(COMMON_CXX_FLAGS)
set(COMMON_CXX_FLAGS "${CFE_CXX_FLAGS} -g")
set(COMMON_CXX_FLAGS "${CFE_CXX_FLAGS} -Wall \
-Wsign-compare")
set(COMMON_CXX_FLAGS "${CFE_CXX_FLAGS} -DEXPORT_PSY_API")


set(CMAKE_MACOSX_RPATH TRUE)

Expand Down
2 changes: 1 addition & 1 deletion common/diagnostics/Diagnostic.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class PSY_API Diagnostic
friend class C::TestFrontend;
};

std::ostream& operator<<(std::ostream& os, const Diagnostic& diagnostic);
PSY_API std::ostream& operator<<(std::ostream& os, const Diagnostic& diagnostic);

} // psy

Expand Down
2 changes: 1 addition & 1 deletion common/location/LinePosition.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ bool operator==(const LinePosition& a, const LinePosition& b);

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

std::ostream& operator<<(std::ostream& os, const LinePosition& pos);
PSY_API std::ostream& operator<<(std::ostream& os, const LinePosition& pos);

} // psy

Expand Down

0 comments on commit 85f39b1

Please sign in to comment.