Skip to content

Commit

Permalink
add shared/static library config
Browse files Browse the repository at this point in the history
  • Loading branch information
emrekovanci committed Apr 18, 2024
1 parent 5bc7fc8 commit 44e1b86
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ jobs:
build_type:
- Debug
- Release
config:
- { name: Shared, flags: -DBUILD_SHARED_LIBS=TRUE }
- { name: Static, flags: -DBUILD_SHARED_LIBS=FALSE }

exclude:
- os: windows-2022
Expand Down Expand Up @@ -59,7 +62,7 @@ jobs:
shell: bash
run: |
if [ "${{ runner.os }}" == "Windows" ]; then
cmake --preset=Windows-${{ matrix.compiler }}-${{ matrix.build_type }}
cmake --preset=Windows-${{ matrix.compiler }}-${{ matrix.build_type }} -DBUILD_SHARED_LIBS=${{ matrix.config.flags }}
else
cmake --preset=${{ matrix.compiler }}-${{ matrix.build_type }}
fi
Expand Down
27 changes: 26 additions & 1 deletion library/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,34 @@ set(LIBRARY_SOURCES
)

# Define library and its properties
add_library(Core STATIC ${LIBRARY_HEADERS} ${LIBRARY_SOURCES})
add_library(Core ${LIBRARY_HEADERS} ${LIBRARY_SOURCES})
target_include_directories(Core PUBLIC ${PROJECT_SOURCE_DIR}/library/include)
target_compile_features(Core PUBLIC cxx_std_17)

include(GenerateExportHeader)
generate_export_header(Core
EXPORT_FILE_NAME Core_Export.h
EXPORT_MACRO_NAME CORE_API
NO_EXPORT_MACRO_NAME CORE_PRIVATE
)
target_sources(Core
PUBLIC
FILE_SET HEADERS
BASE_DIRS ${CMAKE_CURRENT_BINARY_DIR}
FILES ${CMAKE_CURRENT_BINARY_DIR}/Core_Export.h
)

if(NOT BUILD_SHARED_LIBS)
target_compile_definitions(Core PUBLIC CORE_STATIC_DEFINE)
endif()

set_target_properties(Core PROPERTIES
CXX_VISIBILITY_PRESET hidden
VISIBILITY_INLINES_HIDDEN YES
VERSION "${PROJECT_VERSION}"
SOVERSION "${PROJECT_VERSION_MAJOR}"
)

install(TARGETS Core)

if (FEATURE_TESTS)
Expand Down
4 changes: 3 additions & 1 deletion library/include/Core/Lib.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#pragma once

#include "Core_Export.h"

#include <string>

struct Lib
struct CORE_API Lib
{
Lib();

Expand Down

0 comments on commit 44e1b86

Please sign in to comment.