Skip to content

Commit

Permalink
Improve library build
Browse files Browse the repository at this point in the history
  • Loading branch information
Werni2A committed Jun 23, 2024
1 parent b3c5205 commit 679f69c
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 10 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
sudo apt install -y cmake
git clone https://github.com/microsoft/vcpkg.git
./vcpkg/bootstrap-vcpkg.sh
export VCPKG_ROOT=$(realpath .)
- name: Download Unit Test Designs
run: |
Expand All @@ -29,8 +30,8 @@ jobs:
- name: Build Library, CLI Application and Tests
run: |
cmake -B build -DCMAKE_BUILD_TYPE=Release -S . -DENABLE_UNIT_TESTING=1 -DCMAKE_TOOLCHAIN_FILE=vcpkg/scripts/buildsystems/vcpkg.cmake
cmake --build build -j $(nproc)
cmake --preset release -DENABLE_UNIT_TESTING=ON
cmake --build --preset release -j $(nproc)
- name: Run Tests
run: |
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.8)

project(OpenOrCadParser)
project(OpenOrCadParser VERSION 0.1.0)

option(ENABLE_UNIT_TESTING "Enable unit testing" OFF)

Expand Down
23 changes: 23 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"version": 6,
"configurePresets": [
{
"name": "release",
"displayName": "Config Release",
"description": "Configures Release Version",
"binaryDir": "build",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
}
}
],
"buildPresets": [
{
"name": "release",
"displayName": "Build Release",
"description": "Builds Release Version",
"configurePreset": "release"
}
]
}
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,19 @@ git clone https://github.com/microsoft/vcpkg.git
./vcpkg/bootstrap-vcpkg.sh

# Set path to vcpkg
VCPKG_DIR=$(realpath ./vcpkg)
VCPKG_ROOT=$(realpath ./vcpkg)

# Allow parallel builds
export CMAKE_BUILD_PARALLEL_LEVEL=$(nproc)

# Get OpenOrCadParser
git clone https://github.com/Werni2A/OpenOrCadParser.git

cd OpenOrCadParser

# Build
cmake -B build -DCMAKE_BUILD_TYPE=Release -S . -DCMAKE_TOOLCHAIN_FILE=$VCPKG_DIR/scripts/buildsystems/vcpkg.cmake
cmake --build build
cmake --preset release
cmake --build --preset release
```

## Dependencies
Expand Down
4 changes: 2 additions & 2 deletions build_and_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ python3 test/py/testing.py -g 1 -d repos.yaml -u test/src/generated_tests -t tes
echo Building Applications...

# Build applications
cmake -B build -DCMAKE_BUILD_TYPE=Release -S . -DCMAKE_TOOLCHAIN_FILE=../../../vcpkg/scripts/buildsystems/vcpkg.cmake
cmake --build build -j $(nproc)
cmake --preset release -DENABLE_UNIT_TESTING=ON
cmake --build --preset release

echo Running Unit Tests...

Expand Down
31 changes: 31 additions & 0 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,34 @@ target_link_libraries(${NAME_LIB} PRIVATE
spdlog::spdlog_header_only
tinyxml2::tinyxml2
)

set_target_properties(${NAME_LIB} PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR}
)

include(GNUInstallDirs)

install(TARGETS ${NAME_LIB}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/OpenOrCadParser
)

# Install library headers
file(GLOB HEADERS ${LIB_INCLUDE_DIR}/*.hpp)
install(FILES ${HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/OpenOrCadParser)

file(GLOB HEADERS ${LIB_INCLUDE_DIR}/Enums/*.hpp)
install(FILES ${HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/OpenOrCadParser/Enums)

file(GLOB HEADERS ${LIB_INCLUDE_DIR}/Primitives/*.hpp)
install(FILES ${HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/OpenOrCadParser/Primitives)

file(GLOB HEADERS ${LIB_INCLUDE_DIR}/Streams/*.hpp)
install(FILES ${HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/OpenOrCadParser/Streams)

file(GLOB HEADERS ${LIB_INCLUDE_DIR}/Structures/*.hpp)
install(FILES ${HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/OpenOrCadParser/Structures)

file(GLOB HEADERS ${LIB_INCLUDE_DIR}/Win32/*.hpp)
install(FILES ${HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/OpenOrCadParser/Win32)
8 changes: 6 additions & 2 deletions vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "open-orcad-parser",
"name": "openorcadparser",
"version": "0.1.0",
"dependencies": [
"boost-program-options",
Expand All @@ -9,7 +9,11 @@
"magic-enum",
"nameof",
"spdlog",
"tinyxml2"
"tinyxml2",
{
"name": "vcpkg-cmake",
"host": true
}
],
"builtin-baseline": "4d9c5616fe02f0f9d253a11c94f9f582b91115ee"
}

0 comments on commit 679f69c

Please sign in to comment.