Forráskód Böngészése

updating nix-shell and CMake file

Bernardo Magri 1 hónapja
szülő
commit
6cfeda886e
2 módosított fájl, 21 hozzáadás és 12 törlés
  1. 16 12
      CMakeLists.txt
  2. 5 0
      shell.nix

+ 16 - 12
CMakeLists.txt

@@ -51,18 +51,22 @@ FetchContent_Declare(
 )
 FetchContent_MakeAvailable(spdlog)
 
-# Google Test
-FetchContent_Declare(
-    googletest
-    GIT_REPOSITORY https://github.com/google/googletest.git
-    GIT_TAG release-1.11.0 # Or a more recent stable release
-)
-# FetchContent_MakeAvailable(googletest) # This is not enough for subdirectories
-FetchContent_GetProperties(googletest) # Get properties to use SOURCE_DIR and BINARY_DIR
-if(NOT googletest_POPULATED)
-    FetchContent_Populate(googletest)
+# Try to find system GoogleTest first (Nix-shell provided)
+find_package(GTest)
+
+if(GTest_FOUND)
+    message(STATUS "Found system GoogleTest: ${GTest_VERSION}")
+    # Note: System GTest exports targets as GTest::gtest and GTest::gtest_main
+else()
+    message(STATUS "System GoogleTest not found. Fetching via Git...")
+    
+    FetchContent_Declare(
+        googletest
+        GIT_REPOSITORY https://github.com/google/googletest.git
+        GIT_TAG        v1.15.2  # Keep this updated to prevent the MacOS CMake 4.1 error!
+    )
+    FetchContent_MakeAvailable(googletest)
 endif()
-add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR}) # Expose targets to subdirectories
 
 # Core library (UI-independent)
 add_library(lumacs_core STATIC
@@ -132,4 +136,4 @@ endif()
 
 # Enable testing
 enable_testing()
-add_subdirectory(tests)
+add_subdirectory(tests)

+ 5 - 0
shell.nix

@@ -23,6 +23,11 @@ pkgs.mkShell {
 
     # Git for FetchContent
     git
+
+    gtest
+    sol2
+    libsysprof-capture
+    pcre2
   ];
 
   shellHook = ''