diff --git a/.vscode/launch.json b/.vscode/launch.json index 74b74fa9a5ad0bef7fdf8a7dcd34cf0fea833a02..62eb55add2b33aa46bd636ffa5bf5d32c05ec7e4 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -2,77 +2,48 @@ "version": "0.2.0", "configurations": [ { - "name": "Jami-Tests-Run", + "name": "Jami-Client-Debug", "type": "cppdbg", "request": "launch", - "program": "/usr/bin/ctest", - "args": ["-V", "-R"], - "cwd": "${workspaceFolder}/build/tests", - "externalConsole": false, - "environment": [ - { - "name": "HOME", - "value": "/tmp" - } - ] - }, - { - "name": "Jami-Client", - "type": "cppdbg", - "request": "launch", - "program": "${workspaceFolder}/build/jami", - "args": [ - "-d", - ], - "stopAtEntry": false, + "program": "", + "linux":{ + "MIMode": "gdb", + "program": "${workspaceFolder}/build/jami", + "args": [ + "-d", + ], + }, + "osx": { + "MIMode": "lldb", + "program": "${workspaceFolder}/build/Jami.app/Contents/MacOS/Jami", + "environment": [ + { + "name": "NO_COLOR", + "value": "true", + } + ], + }, "cwd": "${workspaceFolder}", - "environment": [], - "externalConsole": false, - "MIMode": "gdb", - "setupCommands": [ - { - "description": "Enable pretty-printing for gdb", - "text": "-enable-pretty-printing", - "ignoreFailures": true - } - ], "preLaunchTask": "cmake-build", - "miDebuggerPath": "/usr/bin/gdb", + "externalConsole": false, // A macOS dev may want to set this to true. }, { + // Using this configuration will require manually reconfiguring the project using + // build.py --no-libwrap, otherwise the daemon executable will not be built and the + // client will not be built with ENABLE_LIBWRAP=False. "name": "Jami-Daemon-Debug", "type": "cppdbg", "request": "launch", - "program": "${workspaceFolder}/daemon/bin/dbus/jamid", + "linux": { + "MIMode": "gdb", + "program": "${workspaceFolder}/daemon/bin/dbus/jamid", + }, + "program": "", "args": [ "-cdp", ], - "stopAtEntry": false, "cwd": "${workspaceFolder}", - "environment": [], - "externalConsole": false, - "MIMode": "gdb", - "setupCommands": [ - { - "description": "Enable pretty-printing for gdb", - "text": "-enable-pretty-printing", - "ignoreFailures": true - } - ], "preLaunchTask": "cmake-build", - "miDebuggerPath": "/usr/bin/gdb", - } - ], - "compounds": [ - { - // Using this configuration will require manually reconfiguring the project using - // build.py --no-libwrap, otherwise the daemon executable will not be built and the - // client will not be built with ENABLE_LIBWRAP=False. - "name": "Jami-Client-IPC", - "configurations": [ - "Jami-Daemon-Debug", - "Jami-Client", - ] } ] } \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json index f31c8b32c25d4f2de616faecc3518f36da53f279..0af4bc9c12876f0101c7fd52e1cb7f69727c879a 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -1,6 +1,27 @@ { "version": "2.0.0", "tasks": [ + { + "label": "run-tests", + "type": "shell", + "command": "ctest", + "options": { + "cwd": "${workspaceFolder}/build/tests", + "env": { + "HOME": "/tmp" + } + }, + "args": [ + "-V", + "-R" + ], + "group": { + "kind": "test", + "isDefault": true + }, + "problemMatcher": [], + "detail": "Run the tests using CTest." + }, { "label": "cmake-configure", "type": "shell", @@ -10,7 +31,19 @@ "-B", "build", "-DCMAKE_BUILD_TYPE=Debug", "-DCMAKE_PREFIX_PATH=\"/usr/lib64/qt-jami;/usr/lib/libqt-jami\"", - "-DBUILD_TESTING=True" + ], + "group": "build", + "problemMatcher": [], + "detail": "Generate the build system files with CMake." + }, + { + "label": "cmake-configure-tests", + "type": "shell", + "command": "cmake", + "args": [ + "-S", ".", + "-B", "build", + "-DBUILD_TESTING=${input:buildTestingInput}" ], "group": "build", "problemMatcher": [], @@ -48,5 +81,13 @@ "problemMatcher": [], "detail": "Clean the build directory." } + ], + "inputs": [ + { + "id": "buildTestingInput", + "type": "pickString", + "description": "Do you want to enable testing?", + "options": ["True", "False"], + } ] } \ No newline at end of file diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index b2730b719557c5c3cfc7dc090705103369eebdc0..6ccd5558f13ce585156b9c6aa2060459ef6f5c49 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -22,15 +22,28 @@ if(MSVC) googletest URL https://github.com/google/googletest/archive/refs/tags/release-1.11.0.zip ) - # for Windows: Prevent overriding the parent project's compiler/linker settings - set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) + if(MSVC) + # for Windows: Prevent overriding the parent project's compiler/linker settings + set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) + endif() FetchContent_MakeAvailable(googletest) +elseif(APPLE) + # Use pkg-config to find gtest on macOS + find_package(PkgConfig REQUIRED) + pkg_search_module(GTEST REQUIRED gtest) + list(APPEND EXTRA_TEST_LIBS ${GTEST_LIBRARIES}) + list(APPEND EXTRA_TEST_LIB_DIRS ${GTEST_LIBRARY_DIRS}) + # Add the link directories to the target + link_directories(${EXTRA_TEST_LIB_DIRS}) + list(APPEND EXTRA_TEST_INCLUDES ${GTEST_INCLUDE_DIRS}) else() find_package(GTest REQUIRED) + list(APPEND EXTRA_TEST_LIBS gtest) endif() set(QML_TEST_LIBS ${QT_LIBS} ${LIBCLIENT_NAME} ${QT_TEST_LIBS}) set(TESTS_INCLUDES + ${EXTRA_TEST_INCLUDES} ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/tests/qml ${CMAKE_SOURCE_DIR}/tests/unittests) @@ -91,7 +104,7 @@ set(UNIT_TESTS_SOURCE_FILES set(ALL_TESTS_LIBS ${QML_TEST_LIBS} - gtest + ${EXTRA_TEST_LIBS} ${CLIENT_LIBS}) set(ALL_TESTS_INCLUDES