Skip to content

Commit

Permalink
Add PARTIO_BUILD_SHARED_LIBS.
Browse files Browse the repository at this point in the history
This acts similar to BUILD_SHARED_LIBS, but it's namespaced, and it
is off by default on Windows as partio does not export any symbols
by default.

Signed-off-by: Matthäus G. Chajdas <[email protected]>
  • Loading branch information
Anteru committed Sep 13, 2020
1 parent b1163a9 commit b16bef6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ jobs:
- name: Get gtest
run: vcpkg install gtest:${{matrix.architecture}}-windows
- name: CMake configure
run: cmake "-DCMAKE_TOOLCHAIN_FILE=$env:VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake" -DBUILD_SHARED_LIBS=OFF -DPARTIO_GTEST_ENABLED=ON -A ${{matrix.architecture}} .
run: cmake "-DCMAKE_TOOLCHAIN_FILE=$env:VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake" -DPARTIO_GTEST_ENABLED=ON -A ${{matrix.architecture}} .
- name: Build
run: cmake --build . --config ${{matrix.config}}
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,14 @@
cmake_minimum_required(VERSION 3.15.0)
project(partio LANGUAGES CXX)

option(BUILD_SHARED_LIBS "Enabled shared libraries" ON)
option(PARTIO_GTEST_ENABLED "Enable GTest for tests" OFF)

if(WIN32)
option(PARTIO_USE_GLVND "Use GLVND for OpenGL" OFF)
option(PARTIO_BUILD_SHARED_LIBS "Enabled shared libraries" OFF)
else()
option(PARTIO_USE_GLVND "Use GLVND for OpenGL" ON)
option(PARTIO_BUILD_SHARED_LIBS "Enabled shared libraries" ON)
endif()

# Enable C++11
Expand Down
7 changes: 6 additions & 1 deletion src/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@
file(GLOB io_cpp "io/*.cpp")
file(GLOB core_cpp "core/*.cpp")

add_library(partio ${io_cpp} ${core_cpp})
if(PARTIO_BUILD_SHARED_LIBS)
set(PARTIO_LIBRARY_TYPE SHARED)
else()
set(PARTIO_LIBRARY_TYPE STATIC)
endif()
add_library(partio ${PARTIO_LIBRARY_TYPE} ${io_cpp} ${core_cpp})
set_target_properties(partio PROPERTIES OUTPUT_NAME partio POSITION_INDEPENDENT_CODE ON)

target_include_directories(partio
Expand Down

0 comments on commit b16bef6

Please sign in to comment.