From 48c574270b7efd99bae3dbc4c1ba2b373232361d Mon Sep 17 00:00:00 2001 From: Chadwick Boulay Date: Mon, 7 Jul 2025 13:45:37 -0400 Subject: [PATCH 01/13] Update runner for MinGW static CI and install cmake in msys2 shell. --- .github/workflows/mingw_static.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/mingw_static.yml b/.github/workflows/mingw_static.yml index 07004ed0..dcebe024 100644 --- a/.github/workflows/mingw_static.yml +++ b/.github/workflows/mingw_static.yml @@ -44,7 +44,7 @@ jobs: -Dlslgitrevision=${{ github.sha }} \ -Dlslgitbranch=${{ github.ref }} \ -DLSL_OPTIMIZATIONS=OFF \ - -G 'MSYS Makefiles' + -G Ninja - name: make run: cmake --build build --target install --config Release -j --verbose From b4f82f41710cc6f19c28e43f4b5e4ff220205578 Mon Sep 17 00:00:00 2001 From: Chadwick Boulay Date: Mon, 7 Jul 2025 14:48:06 -0400 Subject: [PATCH 02/13] mingw - Revert changes; back to windows-2019 which doesn't run; at least we don't get a big red X. --- .github/workflows/mingw_static.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/mingw_static.yml b/.github/workflows/mingw_static.yml index dcebe024..07004ed0 100644 --- a/.github/workflows/mingw_static.yml +++ b/.github/workflows/mingw_static.yml @@ -44,7 +44,7 @@ jobs: -Dlslgitrevision=${{ github.sha }} \ -Dlslgitbranch=${{ github.ref }} \ -DLSL_OPTIMIZATIONS=OFF \ - -G Ninja + -G 'MSYS Makefiles' - name: make run: cmake --build build --target install --config Release -j --verbose From 4a092b37b5f5da7b327aab3a94dec35bd936d4c8 Mon Sep 17 00:00:00 2001 From: Chadwick Boulay Date: Mon, 7 Jul 2025 17:32:47 -0400 Subject: [PATCH 03/13] Keep original order of cmake invocations as much as possible --- cmake/TargetObjLib.cmake | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cmake/TargetObjLib.cmake b/cmake/TargetObjLib.cmake index ad911f80..ae584389 100644 --- a/cmake/TargetObjLib.cmake +++ b/cmake/TargetObjLib.cmake @@ -43,6 +43,18 @@ if(UNIX AND NOT APPLE) endif() elseif(WIN32) target_link_libraries(lslobj PRIVATE iphlpapi winmm mswsock ws2_32) + target_compile_definitions(lslobj + PRIVATE + _CRT_SECURE_NO_WARNINGS + PUBLIC + _WIN32_WINNT=${LSL_WINVER} + ) + if(BUILD_SHARED_LIBS) + # set_target_properties(lslobj + # PROPERTIES + # WINDOWS_EXPORT_ALL_SYMBOLS ON + # ) + endif(BUILD_SHARED_LIBS) endif() # Compiler settings From 60789a5367894b4cb90cb86bc8253b57e888e7b0 Mon Sep 17 00:00:00 2001 From: Chadwick Boulay Date: Mon, 7 Jul 2025 21:20:15 -0400 Subject: [PATCH 04/13] Reorder lslobj cmake commands for slightly more logical grouping. --- cmake/TargetObjLib.cmake | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/cmake/TargetObjLib.cmake b/cmake/TargetObjLib.cmake index ae584389..53ad97fc 100644 --- a/cmake/TargetObjLib.cmake +++ b/cmake/TargetObjLib.cmake @@ -43,10 +43,22 @@ if(UNIX AND NOT APPLE) endif() elseif(WIN32) target_link_libraries(lslobj PRIVATE iphlpapi winmm mswsock ws2_32) +endif() + +# Compiler settings +target_compile_definitions(lslobj + PRIVATE + LIBLSL_EXPORTS + LOGURU_DEBUG_LOGGING=$ + PUBLIC + ASIO_NO_DEPRECATED + $<$:LSLNOAUTOLINK> # don't use #pragma(lib) in CMake builds +) +if(WIN32) target_compile_definitions(lslobj - PRIVATE + PRIVATE _CRT_SECURE_NO_WARNINGS - PUBLIC + PUBLIC _WIN32_WINNT=${LSL_WINVER} ) if(BUILD_SHARED_LIBS) From ef64c82395fc5358c307d07a543d785baac41e1f Mon Sep 17 00:00:00 2001 From: Chadwick Boulay Date: Tue, 8 Jul 2025 01:57:00 -0400 Subject: [PATCH 05/13] Cleanup CMake redundancies and use FILE_SET for headers -- only solution that installed non-flat header tree by transitive dependencies. --- CMakeLists.txt | 3 +-- cmake/Dependencies.cmake | 11 ++++++----- cmake/Installation.cmake | 34 +++------------------------------- cmake/LSLConfig.cmake | 8 -------- cmake/TargetLib.cmake | 25 +++++++++++++------------ cmake/TargetObjLib.cmake | 31 ++++++++++++------------------- cmake/TargetOther.cmake | 2 ++ 7 files changed, 37 insertions(+), 77 deletions(-) delete mode 100644 cmake/LSLConfig.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 98904a83..f9971c52 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 3.16) +cmake_minimum_required (VERSION 3.23) project (liblsl VERSION 1.16.2 LANGUAGES C CXX @@ -17,7 +17,6 @@ include(cmake/SourceFiles.cmake) # include(cmake/TargetObjLib.cmake) # include(cmake/TargetLib.cmake) # include(cmake/Installation.cmake) # -include(cmake/LSLCMake.cmake) include(cmake/TargetOther.cmake) if(LSL_UNITTESTS) diff --git a/cmake/Dependencies.cmake b/cmake/Dependencies.cmake index fd3e4404..116dc6e6 100644 --- a/cmake/Dependencies.cmake +++ b/cmake/Dependencies.cmake @@ -19,14 +19,15 @@ endif() add_library(lslboost INTERFACE) if(LSL_BUNDLED_BOOST) message(STATUS "Using bundled header-only Boost") - target_include_directories(lslboost SYSTEM INTERFACE - $) + target_include_directories(lslboost + SYSTEM INTERFACE + $ + ) else() message(STATUS "Using system Boost") find_package(Boost REQUIRED) - target_compile_definitions(lslboost INTERFACE - lslboost=boost # allows the LSL code base to work with the original Boost namespace/headers - ) + # Map `lslboost` namespace, which LSL code base uses, to system `boost` namespace/headers. + target_compile_definitions(lslboost INTERFACE lslboost=boost) target_link_libraries(lslboost INTERFACE Boost::boost Boost::disable_autolinking) endif() target_compile_definitions(lslboost INTERFACE BOOST_ALL_NO_LIB) diff --git a/cmake/Installation.cmake b/cmake/Installation.cmake index 71003cbc..4d37551a 100644 --- a/cmake/Installation.cmake +++ b/cmake/Installation.cmake @@ -19,30 +19,20 @@ write_basic_package_version_file( # Define installation targets set(LSLTargets lsl) -if(LSL_BUILD_STATIC) - list(APPEND LSLTargets lslobj lslboost) -endif() # Install the targets and store configuration information. install(TARGETS ${LSLTargets} - EXPORT LSLTargets # generates a CMake package config; TODO: Why the same name as the list of targets? + EXPORT LSLTargets COMPONENT liblsl RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} - # If we use CMake 3.23 FILE_SET, replace INCLUDES line with: FILE_SET HEADERS DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} -) - -# TODO: What does this do? Why do we need LSLTargets.cmake in the build dir? -export(EXPORT LSLTargets - FILE "${CMAKE_CURRENT_BINARY_DIR}/LSLTargets.cmake" - NAMESPACE LSL:: + FILE_SET HEADERS DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) # Generate the LSLConfig.cmake file and mark it for installation install(EXPORT LSLTargets - FILE LSLTargets.cmake # TODO: I think we can use this to generate LSLConfig.cmake, no? + FILE LSLConfig.cmake COMPONENT liblsl NAMESPACE "LSL::" DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/LSL @@ -53,28 +43,10 @@ install(EXPORT LSLTargets # INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/lsl) # If we use this method, then we need a corresponding install(FILES ...) command to install the generated file. -# Copy hardcoded CMake files to the build directory. -# TODO: Why bother with this copy? Is it not enough to install (into cmake/LSL)? -configure_file(cmake/LSLCMake.cmake "${CMAKE_CURRENT_BINARY_DIR}/LSLCMake.cmake" COPYONLY) -# TODO: Why bother with this copy? Is it not enough to install (into cmake/LSL)? -# TODO: Why use hardcoded files? We can generate the LSLConfig.cmake. -configure_file(cmake/LSLConfig.cmake "${CMAKE_CURRENT_BINARY_DIR}/LSLConfig.cmake" COPYONLY) - -# Install the public headers. -# TODO: Verify that this is necessary, given that we already installed the INCLUDES above. -# TODO: Verify if it is still necessary to install the headers if we use FILE_SET. -install(DIRECTORY include/ - COMPONENT liblsl - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} -) - # Install the version file and the helper CMake script. install( FILES - # TODO: Keep this. But why does the configure_file(... COPYONLY) above exist? cmake/LSLCMake.cmake - # TODO: Next line shouldn't be necessary if install(EXPORT...) uses LSLConfig.cmake instead of LSLTargets.cmake - ${CMAKE_CURRENT_BINARY_DIR}/LSLConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/LSLConfigVersion.cmake COMPONENT liblsl DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/LSL diff --git a/cmake/LSLConfig.cmake b/cmake/LSLConfig.cmake deleted file mode 100644 index 3d844714..00000000 --- a/cmake/LSLConfig.cmake +++ /dev/null @@ -1,8 +0,0 @@ -if(TARGET lsl AND NOT TARGET LSL::lsl) - add_library(LSL::lsl ALIAS lsl) -endif() - -if(NOT TARGET LSL::lsl) - include("${CMAKE_CURRENT_LIST_DIR}/LSLTargets.cmake") -endif() -include("${CMAKE_CURRENT_LIST_DIR}/LSLCMake.cmake") diff --git a/cmake/TargetLib.cmake b/cmake/TargetLib.cmake index 356c9c66..7e7d515f 100644 --- a/cmake/TargetLib.cmake +++ b/cmake/TargetLib.cmake @@ -6,6 +6,7 @@ set_source_files_properties("src/buildinfo.cpp" LSL_LIBRARY_INFO_STR="${LSL_VERSION_INFO}/link:${LSL_LIB_TYPE}" ) add_library(lsl ${LSL_LIB_TYPE} src/buildinfo.cpp) +add_library(LSL::lsl ALIAS lsl) # Configure main library @@ -23,19 +24,19 @@ if(LSL_FORCE_FANCY_LIBNAME) ) endif() -# Includes. TODO: Can we not inherit these from lslobj? -target_include_directories(lsl - INTERFACE - $ - $ -) +# Link dependencies. The only dependency is lslobj, which contains the bulk of the library code and linkages. +# Note: We link PRIVATE because lslobj exposes extra symbols that are not part of the public API +# but are used by the internal tests. +target_link_libraries(lsl PRIVATE lslobj) -# Link dependencies. The biggest dependency is lslobj, which contains the bulk of the library code. -target_link_libraries(lsl - PRIVATE - lslobj # TODO: If this is public, does that improve inheritance of includes and compile definitions? - lslboost # TODO: Shouldn't be needed -- lslobj already links it - ${PUGIXML_LIBRARIES} +# Set the include directories for the lsl target. +# Note: We had to link lslobj as a PRIVATE dependency, therefore we must manually expose the include directories +get_target_property(LSLOBJ_HEADERS lslobj HEADER_SET) +target_sources(lsl + INTERFACE + FILE_SET HEADERS + BASE_DIRS include + FILES ${LSLOBJ_HEADERS} ) # Set compile definitions for lsl diff --git a/cmake/TargetObjLib.cmake b/cmake/TargetObjLib.cmake index 53ad97fc..a6c4ced9 100644 --- a/cmake/TargetObjLib.cmake +++ b/cmake/TargetObjLib.cmake @@ -1,32 +1,22 @@ # Create object library so all files are only compiled once add_library(lslobj OBJECT ${lslsources} - ${lslheaders} +# ${lslheaders} # Headers are added later using FILE_SET ) # Set the includes/headers for the lslobj target -# Note: We cannot use the PUBLIC_HEADER property of the target, because -# it flattens the include directories. -# We could use the new FILE_SET feature that comes with CMake 3.23. -# This is how it would look. Note that HEADERS is a special set name and implies its type. -#target_sources(lslobj -# PUBLIC -# FILE_SET HEADERS -# BASE_DIRS include -# FILES ${lslheaders} -#) -# We settle on the older and more common target_include_directories PUBLIC approach. -# If we used the FILET_SET approach then we would remove the PUBLIC includes below. -target_include_directories(lslobj - PUBLIC - $ - $ +# Note: We cannot use the PUBLIC_HEADER property of the target, +# because it flattens the include directories. +# Note: IME, this approach is less error prone than target_include_directories +target_sources(lslobj INTERFACE - # Propagate include directories to consumers - $ # for unit tests + FILE_SET HEADERS # special set name; implies TYPE. + BASE_DIRS include + FILES ${lslheaders} ) # Link system libs +# (boost might be bundled or system) target_link_libraries(lslobj PRIVATE lslboost Threads::Threads) if(MINGW) target_link_libraries(lslobj PRIVATE bcrypt) @@ -96,6 +86,8 @@ endif(WIN32) # Link in 3rd party dependencies # - loguru and asio header-only target_include_directories(lslobj + # Note: We use `SYSTEM` to suppress warnings from 3rd party headers and put these at the end of the include path. + # Note: We use `PUBLIC` because 'internal tests' import individual source files and link lslobj. SYSTEM PUBLIC $ $ @@ -112,6 +104,7 @@ if(NOT LSL_OPTIMIZATIONS) endif() # - pugixml +# Note: We use `PUBLIC` because 'internal tests' import individual source files and link lslobj. if(LSL_BUNDLED_PUGIXML) target_sources(lslobj PRIVATE thirdparty/pugixml/pugixml.cpp) target_include_directories(lslobj diff --git a/cmake/TargetOther.cmake b/cmake/TargetOther.cmake index 32b66dab..9900f4b3 100644 --- a/cmake/TargetOther.cmake +++ b/cmake/TargetOther.cmake @@ -1,3 +1,5 @@ +include(cmake/LSLCMake.cmake) # Needed for `installLSLApp` + # Build utilities add_executable(lslver testing/lslver.c) target_link_libraries(lslver PRIVATE lsl) From 479674bf1007ae0f645d03cb2982470f164e6b3c Mon Sep 17 00:00:00 2001 From: Chadwick Boulay Date: Sat, 12 Jul 2025 13:39:24 -0400 Subject: [PATCH 06/13] Remove examples from primary build because they were relying on in-tree artifacts and thus were masking installation issues --- .github/workflows/cppcmake.yml | 8 ++++- .gitignore | 1 + CMakeLists.txt | 5 ---- examples/CMakeLists.txt | 53 +++++++++++++++++++++++++++++----- examples/HandleMetaData.cpp | 4 +-- 5 files changed, 55 insertions(+), 16 deletions(-) diff --git a/.github/workflows/cppcmake.yml b/.github/workflows/cppcmake.yml index 7788fa99..65399119 100644 --- a/.github/workflows/cppcmake.yml +++ b/.github/workflows/cppcmake.yml @@ -62,7 +62,6 @@ jobs: -DCMAKE_INSTALL_PREFIX=${PWD}/install \ -DLSL_UNITTESTS=ON \ -DLSL_BENCHMARKS=ON \ - -DLSL_BUILD_EXAMPLES=ON \ -DCPACK_PACKAGE_DIRECTORY=${PWD}/package \ -Dlslgitrevision=${{ github.sha }} \ -Dlslgitbranch=${{ github.ref }} \ @@ -71,6 +70,13 @@ jobs: echo ${PWD} - name: make run: cmake --build build --target install --config Release -j + + - name: test install using examples + run: | + # Test that the in-tree install was successful by building the examples + cmake -S examples -B examples/build -DLSL_INSTALL_ROOT=${PWD}/install -DCMAKE_INSTALL_PREFIX=examples/build/install -DLSL_COMFY_DEFAULTS=ON + cmake --build examples/build --target install --config Release -j + ./examples/build/install/bin/HandleMetaData - name: package run: | diff --git a/.gitignore b/.gitignore index 95e7a65f..d30f711d 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ # CLion .idea/ /cmake-build-*/ +/examples/build*/ diff --git a/CMakeLists.txt b/CMakeLists.txt index f9971c52..c4e0dea1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,11 +23,6 @@ if(LSL_UNITTESTS) add_subdirectory(testing) endif() -if(LSL_BUILD_EXAMPLES) - set(LSL_INSTALL_ROOT ${CMAKE_CURRENT_BINARY_DIR}) - add_subdirectory(examples) -endif() - # Config for packaging # TODO: Config for packaging for the library itself is likely to diverge from config for packing applications. e.g., # -> Optionally install to system directories diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index eca4d200..9f93a3d4 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,15 +1,21 @@ -cmake_minimum_required(VERSION 3.12) +cmake_minimum_required(VERSION 3.23) project(lslexamples LANGUAGES C CXX VERSION 0.2.0) find_package(LSL REQUIRED - HINTS ${LSL_INSTALL_ROOT} - "${CMAKE_CURRENT_LIST_DIR}/../build" - "${CMAKE_CURRENT_LIST_DIR}/../out/x64-Release" - PATH_SUFFIXES share/LSL) + HINTS + ${LSL_INSTALL_ROOT} + "${CMAKE_CURRENT_LIST_DIR}/../install" # GHA scripts default install directory + "${CMAKE_CURRENT_LIST_DIR}/../cmake-build-release/install" # CLion default if using -DCMAKE_INSTALL_PREFIX=install + "${CMAKE_CURRENT_LIST_DIR}/../out/x64-Release/install" # MSVC default if using -DCMAKE_INSTALL_PREFIX=install TODO: Check this + PATH_SUFFIXES share/LSL +) get_filename_component(LSL_PATH ${LSL_CONFIG} DIRECTORY) message(STATUS "Found LSL lib in ${LSL_PATH}") -message(STATUS "LSL BIN DIR: ${liblsl_BINARY_DIR} & ${LIBLSL_BINARY_DIR}") + +# Include the LSLCMake.cmake file, just for testing. +# This doesn't do much for us now that we don't use installLSLApp() anymore. +include("${LSL_PATH}/LSLCMake.cmake") # convenience function to add an example file # this creates a target, links the necessary libraries and @@ -20,7 +26,39 @@ function(addlslexample name extension) ) target_link_libraries(${name} PRIVATE LSL::lsl) target_compile_features(${name} PRIVATE cxx_constexpr) - installLSLApp(${name}) + + # Set RPATH properties for macOS and Linux + set_target_properties(${name} PROPERTIES + INSTALL_RPATH_USE_LINK_PATH TRUE + BUILD_WITH_INSTALL_RPATH FALSE + ) + + # One might also want to do the following, to give the option of copying the + # LSL library to the same directory or install tree as the executable. + # However, this is not necessary for the examples, as they are not intended to be relocated. +# if(APPLE) +# set_target_properties(${name} PROPERTIES +# INSTALL_RPATH "@loader_path;@loader_path/../lib" +# ) +# elseif(UNIX) +# set_target_properties(${name} PROPERTIES +# INSTALL_RPATH "$ORIGIN:$ORIGIN/../lib" +# ) +# endif() + + install(TARGETS ${name} + COMPONENT ${PROJECT_NAME} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + ) + if(WIN32) + # On Windows, we need to copy the DLLs to the same directory as the executable + # if we wish to run the example without putting the DLLs in the PATH. + install( + FILES $ + DESTINATION ${CMAKE_INSTALL_BINDIR} + COMPONENT ${PROJECT_NAME} + ) + endif(WIN32) endfunction() find_package(Threads) @@ -46,4 +84,3 @@ addlslexample(SendStringMarkersC c) addlslexample(TestSyncWithoutData cpp) target_link_libraries(TestSyncWithoutData PRIVATE Threads::Threads) - diff --git a/examples/HandleMetaData.cpp b/examples/HandleMetaData.cpp index dffe43d7..f56fd561 100644 --- a/examples/HandleMetaData.cpp +++ b/examples/HandleMetaData.cpp @@ -43,7 +43,7 @@ int main(int argc, char *argv[]) { } } catch (std::exception &e) { std::cerr << "Got an exception: " << e.what() << std::endl; } - std::cout << "Press any key to exit. " << std::endl; - std::cin.get(); + // std::cout << "Press any key to exit. " << std::endl; + // std::cin.get(); return 0; } From d92ef25fe07da2e439b4fb1465c0779fb349ea39 Mon Sep 17 00:00:00 2001 From: Chadwick Boulay Date: Sat, 12 Jul 2025 15:26:32 -0400 Subject: [PATCH 07/13] LSL_BUILD_EXAMPLES option removed from ProjectOptions.cmake --- cmake/ProjectOptions.cmake | 1 - 1 file changed, 1 deletion(-) diff --git a/cmake/ProjectOptions.cmake b/cmake/ProjectOptions.cmake index f0f605d0..48f4c565 100644 --- a/cmake/ProjectOptions.cmake +++ b/cmake/ProjectOptions.cmake @@ -7,7 +7,6 @@ option(LSL_OPTIMIZATIONS "Enable some more compiler optimizations" ON) option(LSL_BUNDLED_BOOST "Use the bundled Boost by default" ON) option(LSL_BUNDLED_PUGIXML "Use the bundled pugixml by default" ON) option(LSL_TOOLS "Build some experimental tools for in-depth tests" OFF) -option(LSL_BUILD_EXAMPLES "Build example programs in examples/" OFF) option(LSL_UNITTESTS "Build LSL library unit tests" OFF) option(LSL_FORCE_FANCY_LIBNAME "Add library name decorations (32/64/-debug)" OFF) mark_as_advanced(LSL_FORCE_FANCY_LIBNAME) From 54e0aaf6e69f3bfbd3a1fb85e4d427d3e7318f17 Mon Sep 17 00:00:00 2001 From: Chadwick Boulay Date: Sat, 12 Jul 2025 16:19:42 -0400 Subject: [PATCH 08/13] Fixup handling the .dll file for the examples. --- examples/CMakeLists.txt | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 9f93a3d4..3f8789d9 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -2,12 +2,16 @@ cmake_minimum_required(VERSION 3.23) project(lslexamples LANGUAGES C CXX VERSION 0.2.0) + +include(GNUInstallDirs) + find_package(LSL REQUIRED HINTS ${LSL_INSTALL_ROOT} "${CMAKE_CURRENT_LIST_DIR}/../install" # GHA scripts default install directory "${CMAKE_CURRENT_LIST_DIR}/../cmake-build-release/install" # CLion default if using -DCMAKE_INSTALL_PREFIX=install - "${CMAKE_CURRENT_LIST_DIR}/../out/x64-Release/install" # MSVC default if using -DCMAKE_INSTALL_PREFIX=install TODO: Check this + "${CMAKE_CURRENT_LIST_DIR}/../cmake-build-release-visual-studio/install" # CLion default if using VS compiler + "${CMAKE_CURRENT_LIST_DIR}/../out/build/x64-Release/install" # MSVC default if using -DCMAKE_INSTALL_PREFIX=install PATH_SUFFIXES share/LSL ) get_filename_component(LSL_PATH ${LSL_CONFIG} DIRECTORY) @@ -50,15 +54,6 @@ function(addlslexample name extension) COMPONENT ${PROJECT_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ) - if(WIN32) - # On Windows, we need to copy the DLLs to the same directory as the executable - # if we wish to run the example without putting the DLLs in the PATH. - install( - FILES $ - DESTINATION ${CMAKE_INSTALL_BINDIR} - COMPONENT ${PROJECT_NAME} - ) - endif(WIN32) endfunction() find_package(Threads) @@ -84,3 +79,19 @@ addlslexample(SendStringMarkersC c) addlslexample(TestSyncWithoutData cpp) target_link_libraries(TestSyncWithoutData PRIVATE Threads::Threads) + +# Windows doesn't have RPATH so we put the dll into the same directory as the executable. +if(WIN32) + # For one of the targets, copy the lsl.dll into the build directory so we can debug the examples if needed. + add_custom_command(TARGET HandleMetaData POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + "$" + $ + COMMENT "Copying lsl.dll to examples build directory" + ) + # Install the lsl.dll to the same directory as the executable. + install( + CODE "file(INSTALL DESTINATION \"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}\" TYPE SHARED_LIBRARY FILES \"$\")" + COMPONENT ${PROJECT_NAME} + )#install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different \"$\" \"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}\")") +endif() From 6f742dd0dcf023899c44a8c7c88374276ff0360b Mon Sep 17 00:00:00 2001 From: Chadwick Boulay Date: Sat, 12 Jul 2025 22:22:25 -0400 Subject: [PATCH 09/13] Try to fix cppcmake.yml for Win x32 --- .github/workflows/cppcmake.yml | 7 ++++++- examples/CMakeLists.txt | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cppcmake.yml b/.github/workflows/cppcmake.yml index 65399119..4e158956 100644 --- a/.github/workflows/cppcmake.yml +++ b/.github/workflows/cppcmake.yml @@ -74,7 +74,12 @@ jobs: - name: test install using examples run: | # Test that the in-tree install was successful by building the examples - cmake -S examples -B examples/build -DLSL_INSTALL_ROOT=${PWD}/install -DCMAKE_INSTALL_PREFIX=examples/build/install -DLSL_COMFY_DEFAULTS=ON + cmake -S examples -B examples/build \ + -DLSL_INSTALL_ROOT=${PWD}/install \ + -DCMAKE_INSTALL_PREFIX=examples/build/install \ + -DLSL_COMFY_DEFAULTS=ON \ + ${{ matrix.config.cmake_extra }} \ + ${{ github.event.inputs.cmakeextra }} cmake --build examples/build --target install --config Release -j ./examples/build/install/bin/HandleMetaData diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 3f8789d9..aa997882 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -93,5 +93,5 @@ if(WIN32) install( CODE "file(INSTALL DESTINATION \"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}\" TYPE SHARED_LIBRARY FILES \"$\")" COMPONENT ${PROJECT_NAME} - )#install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different \"$\" \"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}\")") + ) endif() From 1e74634dfcb5bb6e4f31cc97a80ebb56999eeef4 Mon Sep 17 00:00:00 2001 From: Chadwick Boulay Date: Sun, 13 Jul 2025 10:57:55 -0400 Subject: [PATCH 10/13] Trying to get msys2 builds working again. --- .github/workflows/mingw_static.yml | 40 +++++++++++++++++++----------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/.github/workflows/mingw_static.yml b/.github/workflows/mingw_static.yml index 07004ed0..fbdc951c 100644 --- a/.github/workflows/mingw_static.yml +++ b/.github/workflows/mingw_static.yml @@ -1,14 +1,16 @@ name: MinGW Windows static test on: -# push: -# branches: ['*'] -# paths: -# - '**' + push: + branches: ['*'] + paths: + - 'src' + - 'include' + - 'cmake' # - '!docs/**' # - '!.github/**' -# - '.github/workflows/mingw_static.yml' -# pull_request: + - '.github/workflows/mingw_static.yml' + pull_request: workflow_dispatch: concurrency: @@ -18,20 +20,31 @@ concurrency: jobs: build: name: MinGW batteries-included - runs-on: windows-2019 - + strategy: + matrix: + include: +# - { sys: mingw64, env: x86_64 } +# - { sys: mingw32, env: i686 } + - { sys: ucrt64, env: ucrt-x86_64 } +# - { sys: clang64, env: clang-x86_64 } + runs-on: windows-latest defaults: run: shell: 'msys2 {0}' - steps: - uses: actions/checkout@v4 - uses: msys2/setup-msys2@v2 with: - release: false + msystem: ${{matrix.sys}} + update: true cache: true -# install: >- -# cmake + install: >- + git + make + pacboy: >- + toolchain:p + cmake:p + ninja:p - name: Configure CMake run: | cmake --version @@ -39,12 +52,11 @@ jobs: -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=${PWD}/install \ -DLSL_UNITTESTS=ON \ - -DLSL_BUILD_EXAMPLES=ON \ -DLSL_BUILD_STATIC=ON \ -Dlslgitrevision=${{ github.sha }} \ -Dlslgitbranch=${{ github.ref }} \ -DLSL_OPTIMIZATIONS=OFF \ - -G 'MSYS Makefiles' + -G Ninja - name: make run: cmake --build build --target install --config Release -j --verbose From 78383552392cce4d31128f16a93650551e321aca Mon Sep 17 00:00:00 2001 From: Chadwick Boulay Date: Sun, 13 Jul 2025 11:11:28 -0400 Subject: [PATCH 11/13] Re-add lslobj and lslboost to installation targets when static --- cmake/Installation.cmake | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmake/Installation.cmake b/cmake/Installation.cmake index 4d37551a..44f99839 100644 --- a/cmake/Installation.cmake +++ b/cmake/Installation.cmake @@ -19,6 +19,9 @@ write_basic_package_version_file( # Define installation targets set(LSLTargets lsl) +if(LSL_BUILD_STATIC) + list(APPEND LSLTargets lslobj lslboost) +endif() # Install the targets and store configuration information. install(TARGETS ${LSLTargets} From 57c3ffb8f354ef211973a8229db9d733545d2443 Mon Sep 17 00:00:00 2001 From: Chadwick Boulay Date: Sun, 13 Jul 2025 12:01:28 -0400 Subject: [PATCH 12/13] Do not use SYSTEM when explicitly including BUNDLED bost and pugixml --- cmake/Dependencies.cmake | 2 +- cmake/TargetObjLib.cmake | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/Dependencies.cmake b/cmake/Dependencies.cmake index 116dc6e6..80573762 100644 --- a/cmake/Dependencies.cmake +++ b/cmake/Dependencies.cmake @@ -20,7 +20,7 @@ add_library(lslboost INTERFACE) if(LSL_BUNDLED_BOOST) message(STATUS "Using bundled header-only Boost") target_include_directories(lslboost - SYSTEM INTERFACE + INTERFACE $ ) else() diff --git a/cmake/TargetObjLib.cmake b/cmake/TargetObjLib.cmake index a6c4ced9..4e32ef79 100644 --- a/cmake/TargetObjLib.cmake +++ b/cmake/TargetObjLib.cmake @@ -108,7 +108,7 @@ endif() if(LSL_BUNDLED_PUGIXML) target_sources(lslobj PRIVATE thirdparty/pugixml/pugixml.cpp) target_include_directories(lslobj - SYSTEM PUBLIC + PUBLIC $ ) else() From c1d3ebef84d87af00d838b96241f99a67ddea6ea Mon Sep 17 00:00:00 2001 From: Chadwick Boulay Date: Sun, 13 Jul 2025 13:08:14 -0400 Subject: [PATCH 13/13] Delete deprecated travis config and badge --- .travis.yml | 31 ------------------------------- README.md | 1 - 2 files changed, 32 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 158efe7f..00000000 --- a/.travis.yml +++ /dev/null @@ -1,31 +0,0 @@ -language: cpp -env: - CMakeArgs="" -# https://docs.travis-ci.com/user/reference/osx/#macos-version -matrix: - include: - - os: osx - osx_image: xcode10.1 - env: OSXVER=MacOS10.13 -before_script: -- brew update -- brew upgrade cmake -script: -- cmake --version -- cmake -S . -B build ${CMakeArgs} -DLSL_UNITTESTS=ON -DLSL_EXAMPLES=ON -- cd build -- cmake --build . --config Release -j --target install -- testing/lsl_test_internal || true -- testing/lsl_test_exported -- cpack -- cd .. -deploy: - provider: releases - skip_cleanup: true - api_key: - secure: MAin7yY6lRQNC7gLeE/aDGA90a2TZPjAwQGofyuGvih5T0p3OdKxFn64/lFzEWqb3x74MEu6I4AMteL/wjkminlHGn8fd1bSLtp+2TvnKFnaCuxuhlCNX4BmP741MHEmNMTo8qA+StuxDxwfHh8KVjuFxOkiLV9FolSpxZ3jhl8mBi3IMDodilyfsCniAw/WzekfATkJwmhQ9co642rkTwBKZ7goxdXJmewjEjBsiFn2SUT2+MCcy7NltjYvPdSrUH1LyhVKcSJch7lXqFnlGI21mJxlYdOhd9rA6wOYRZ1hzBRpqAWzE8kbDapMMOfLWrLQP+t5U3WZrt5e7Na/iuopYgzofgfzGr4xK0NwHUuHpc8C1Fair3nOke8IGNDraVHcZazEsBwxv5ekCUTOUFr5lka+ukcznP7PDw2ksIbpOR7bb9G2ubkQT4bDzIfMMOJSPzUbeTN+ds6xiVXukndMsXVW1rkZXk7O4uA60hGWBpX8okddask81Fk6jIBXdJomiRySDfd1DvP16vDGOfei2GZFX8iSvvATQIEE8CCL750vgUuEPPeRvyug2m6+CerAjvH73fmtGiKDmeaQNz+eBnbBpMphKCUvKRpSjSsBPNsQH/epPo34JnUczfzVbZGNNv87OeHDz7POe5YY6+PSwJbfIusPTMY6VdI/g9U= - file: build/*.tar.* - file_glob: true - on: - repo: sccn/liblsl - tags: true diff --git a/README.md b/README.md index 3aa22a44..961edfa6 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@ [![GitHub Actions Status](https://github.com/sccn/liblsl/workflows/C%2FC++%20CI/badge.svg)](https://github.com/sccn/liblsl/actions) -[![Travis Build Status](https://travis-ci.org/sccn/liblsl.svg?branch=master)](https://travis-ci.org/sccn/liblsl) [![Azure Build Status](https://dev.azure.com/labstreaminglayer/liblsl/_apis/build/status/sccn.liblsl?branchName=master)](https://dev.azure.com/labstreaminglayer/liblsl/_build/latest?definitionId=1&branchName=master) [![DOI](https://zenodo.org/badge/123265865.svg)](https://zenodo.org/badge/latestdoi/123265865)