Skip to content

Commit

Permalink
Add support for compilation and test on Windows
Browse files Browse the repository at this point in the history
Tested on Visual Studio 2022
  • Loading branch information
traversaro committed Feb 9, 2024
1 parent cebc67c commit fe267b8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
18 changes: 18 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)")
add_compile_options(-Werror -Wall -Wextra -Wpedantic -Wshadow -Wconversion -Wsign-conversion -Wold-style-cast)
endif()

if(MSVC)
# On Windows, also ensure that all .dll libraries are placed in the
# same build directory so they can be found by the loader (there is
# no rpath on Windows)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}")
endif()

option(BUILD_SHARED_LIBS "Build shared libraries" ON)

add_library(rsl
Expand All @@ -30,6 +37,17 @@ target_link_libraries(rsl PUBLIC
tl_expected::tl_expected
)

# There is no explicit export of symbols in the library either via
# hand-written ***_export.h headers or generate_export_header CMake macro,
# as the header-only functions in this library are quite limited in number,
# it is perfectly ok to export all of them (as done in *nix) with the
# WINDOWS_EXPORT_ALL_SYMBOLS property
if(MSVC)
set_target_properties(rsl PROPERTIES
WINDOWS_EXPORT_ALL_SYMBOLS TRUE
)
endif()

add_subdirectory(docs)

option(RSL_BUILD_TESTING "Build tests" OFF)
Expand Down
7 changes: 4 additions & 3 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ add_executable(test-rsl
parameter_validators.cpp
queue.cpp
random.cpp
static_string.cpp
static_vector.cpp
strong_type.cpp
try.cpp)
strong_type.cpp)
if(NOT MSVC)
target_sources(test-rsl try.cpp static_string.cpp)
endif()
target_link_libraries(test-rsl PRIVATE
rsl::rsl
Catch2::Catch2WithMain
Expand Down

0 comments on commit fe267b8

Please sign in to comment.