diff --git a/.gitignore b/.gitignore index 1b452285..fbfedc8a 100644 --- a/.gitignore +++ b/.gitignore @@ -81,3 +81,4 @@ cmake-build-*/ *.tcl *.user *.sln +/output diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index f982f45b..d69ddeff 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -11,17 +11,22 @@ endif() # --------------------------------------------------------------------------------------- # Example of using shared libraries # --------------------------------------------------------------------------------------- -add_library(mylibrary SHARED mylibrary.cpp mylibrary.h) -target_link_libraries(mylibrary PRIVATE spdlog::spdlog) -target_compile_definitions(mylibrary PUBLIC SPDLOG_COMPILED_LIB) - -add_executable(library_example library_example.cpp) -target_link_libraries(library_example PRIVATE spdlog::spdlog mylibrary) -target_compile_definitions(library_example PUBLIC SPDLOG_COMPILED_LIB) - if(SPDLOG_BUILD_SHARED OR BUILD_SHARED_LIBS) + add_library(mylibrary SHARED mylibrary.cpp mylibrary.h) + target_link_libraries(mylibrary PRIVATE spdlog::spdlog) target_compile_definitions(mylibrary PUBLIC SPDLOG_SHARED_LIB) + target_compile_definitions(mylibrary PUBLIC SPDLOG_COMPILED_LIB) + + add_executable(library_example library_example.cpp) + target_link_libraries(library_example PRIVATE spdlog::spdlog mylibrary) target_compile_definitions(library_example PUBLIC SPDLOG_SHARED_LIB) + target_compile_definitions(library_example PUBLIC SPDLOG_COMPILED_LIB) +else() + add_library(mylibrary SHARED mylibrary.cpp mylibrary.h) + target_link_libraries(mylibrary PRIVATE spdlog::spdlog_header_only) + + add_executable(library_example library_example.cpp) + target_link_libraries(library_example PRIVATE spdlog::spdlog_header_only mylibrary) endif() # ---------------------------------------------------------------------------------------