Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating per-library EXPORT symbols #44

Merged
merged 2 commits into from
Sep 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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