Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ macro(CMAKE_HANDLE_SYSTEM_LIBRARIES)

# Allow the user to enable/disable all system utility library options by
# defining CMAKE_USE_SYSTEM_LIBRARIES or CMAKE_USE_SYSTEM_LIBRARY_${util}.
set(UTILITIES BZIP2 CURL EXPAT FORM JSONCPP LIBARCHIVE LIBLZMA LIBRHASH LIBUV NGHTTP2 ZLIB ZSTD)
set(UTILITIES BZIP2 CPPDAP CURL EXPAT FORM JSONCPP LIBARCHIVE LIBLZMA LIBRHASH LIBUV NGHTTP2 NLOHMANNJSON ZLIB ZSTD)
foreach(util IN LISTS UTILITIES)
if(NOT DEFINED CMAKE_USE_SYSTEM_LIBRARY_${util}
AND DEFINED CMAKE_USE_SYSTEM_LIBRARIES)
Expand Down Expand Up @@ -185,6 +185,8 @@ macro(CMAKE_HANDLE_SYSTEM_LIBRARIES)
option(CMAKE_USE_SYSTEM_JSONCPP "Use system-installed jsoncpp" "${CMAKE_USE_SYSTEM_LIBRARY_JSONCPP}")
option(CMAKE_USE_SYSTEM_LIBRHASH "Use system-installed librhash" "${CMAKE_USE_SYSTEM_LIBRARY_LIBRHASH}")
option(CMAKE_USE_SYSTEM_LIBUV "Use system-installed libuv" "${CMAKE_USE_SYSTEM_LIBRARY_LIBUV}")
option(CMAKE_USE_SYSTEM_NLOHMANNJSON "Use system-installed nlohmann_json" "${CMAKE_USE_SYSTEM_LIBRARY_NLOHMANNJSON}")
option(CMAKE_USE_SYSTEM_CPPDAP "Use system-installed cppdap" "${CMAKE_USE_SYSTEM_LIBRARY_CPPDAP}")

# For now use system KWIML only if explicitly requested rather
# than activating via the general system libs options.
Expand Down
2 changes: 2 additions & 0 deletions Source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,7 @@ target_include_directories(
target_link_libraries(
CMakeLib
PUBLIC
cppdap::cppdap
cmstd
cmsys
CURL::libcurl
Expand All @@ -758,6 +759,7 @@ target_link_libraries(
LibArchive::LibArchive
LibRHash::LibRHash
LibUV::LibUV
nlohmann_json::nlohmann_json
Threads::Threads
ZLIB::ZLIB
)
Expand Down
47 changes: 47 additions & 0 deletions Source/Modules/CMakeBuildUtilities.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -377,3 +377,50 @@ if(BUILD_CursesDialog)
message(FATAL_ERROR "CMAKE_USE_SYSTEM_FORM in ON but CURSES_FORM_LIBRARY is not set!")
endif()
endif()

#---------------------------------------------------------------------
# Build nlohmann_json library.
if(CMAKE_USE_SYSTEM_NLOHMANNJSON)
find_package(nlohmann_json 3.11.2)
if(NOT nlohmann_json_FOUND)
message(FATAL_ERROR
"CMAKE_USE_SYSTEM_NLOHMANNJSON is ON but a nlohmann_json is not found!")
endif()
else()
set(JSON_BuildTests OFF)
set(JSON_CI OFF)
set(JSON_Diagnostics OFF)
set(JSON_GlobalUDLs ON)
set(JSON_ImplicitConversions ON)
set(JSON_DisableEnumSerialization OFF)
set(JSON_LegacyDiscardedValueComparison OFF)
set(JSON_Install OFF)
set(JSON_MultipleHeaders ON)
set(JSON_SystemInclude OFF)
add_subdirectory(Utilities/cmnlohmann_json)
CMAKE_SET_TARGET_FOLDER(nlohmann_json "Utilities/3rdParty")
endif()

#---------------------------------------------------------------------
# Build cppdap library.
if(CMAKE_USE_SYSTEM_CPPDAP)
find_package(cppdap)
if(NOT CPPDAP_FOUND)
message(FATAL_ERROR
"CMAKE_USE_SYSTEM_CPPDAP is ON but a cppdap is not found!")
endif()
else()
set(CPPDAP_WARNINGS_AS_ERRORS OFF)
set(CPPDAP_BUILD_EXAMPLES OFF)
set(CPPDAP_BUILD_TESTS OFF)
set(CPPDAP_BUILD_FUZZER OFF)
set(CPPDAP_ASAN OFF)
set(CPPDAP_MSAN OFF)
set(CPPDAP_TSAN OFF)
set(CPPDAP_INSTALL_VSCODE_EXAMPLES OFF)
set(CPPDAP_THIRD_PARTY_DIR ${CMake_SOURCE_DIR}/Utilities)
set(CPPDAP_JSON_DIR ${CMake_SOURCE_DIR}/Utilities/cmnlohmann_json)
add_subdirectory(Utilities/cmcppdap)
add_library(cppdap::cppdap ALIAS cppdap)
CMAKE_SET_TARGET_FOLDER(cppdap "Utilities/3rdParty")
endif()
83 changes: 83 additions & 0 deletions Source/Modules/Findcppdap.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.

#[=======================================================================[.rst:
Findcppdap
---------

Find cppdap includes and library.

Imported Targets
^^^^^^^^^^^^^^^^

An :ref:`imported target <Imported targets>` named
``cppdap::cppdap`` is provided if cppdap has been found.

Result Variables
^^^^^^^^^^^^^^^^

This module defines the following variables:

``cppdap_FOUND``
True if cppdap was found, false otherwise.
``cppdap_INCLUDE_DIRS``
Include directories needed to include cppdap headers.
``cppdap_LIBRARIES``
Libraries needed to link to cppdap.
``cppdap_VERSION``
The version of cppdap found.
``cppdap_VERSION_MAJOR``
The major version of cppdap.
``cppdap_VERSION_MINOR``
The minor version of cppdap.
``cppdap_VERSION_PATCH``
The patch version of cppdap.

Cache Variables
^^^^^^^^^^^^^^^

This module uses the following cache variables:

``cppdap_LIBRARY``
The location of the cppdap library file.
``cppdap_INCLUDE_DIR``
The location of the cppdap include directory containing ``dap.h``.

The cache variables should not be used by project code.
They may be set by end users to point at cppdap components.
#]=======================================================================]

#-----------------------------------------------------------------------------
find_library(cppdap_LIBRARY
NAMES cppdap
)
mark_as_advanced(cppdap_LIBRARY)

find_path(cppdap_INCLUDE_DIR
NAMES dap/dap.h
PATH_SUFFIXES cppdap
)
mark_as_advanced(cppdap_INCLUDE_DIR)

#-----------------------------------------------------------------------------
include(${CMAKE_CURRENT_LIST_DIR}/../../Modules/FindPackageHandleStandardArgs.cmake)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(cppdap
FOUND_VAR cppdap_FOUND
REQUIRED_VARS cppdap_LIBRARY cppdap_INCLUDE_DIR
VERSION_VAR cppdap_VERSION
)
set(cppdap_FOUND ${cppdap_FOUND})

#-----------------------------------------------------------------------------
# Provide documented result variables and targets.
if(cppdap_FOUND)
set(cppdap_INCLUDE_DIRS ${cppdap_INCLUDE_DIR})
set(cppdap_LIBRARIES ${cppdap_LIBRARY})
if(NOT TARGET cppdap::cppdap)
add_library(cppdap::cppdap UNKNOWN IMPORTED)
set_target_properties(cppdap::cppdap PROPERTIES
IMPORTED_LOCATION "${cppdap_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${cppdap_INCLUDE_DIRS}"
)
endif()
endif()
104 changes: 104 additions & 0 deletions Source/Modules/Findnlohmann_json.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.

#[=======================================================================[.rst:
FindNLohmannJson
----------------

Find nlohmann_json includes and library.

Imported Targets
^^^^^^^^^^^^^^^^

An :ref:`imported target <Imported targets>` named
``nlohmann_json::nlohmann_json`` is provided if nlohmann_json has been found.

Result Variables
^^^^^^^^^^^^^^^^

This module defines the following variables:

``nlohmann_json_FOUND``
True if nlohmann_json was found, false otherwise.
``nlohmann_json_INCLUDE_DIRS``
Include directories needed to include nlohmann_json headers.
``nlohmann_json_LIBRARIES``
Libraries needed to link to nlohmann_json.
``nlohmann_json_VERSION``
The version of nlohmann_json found.
``nlohmann_json_VERSION_MAJOR``
The major version of nlohmann_json.
``nlohmann_json_VERSION_MINOR``
The minor version of nlohmann_json.
``nlohmann_json_VERSION_PATCH``
The patch version of nlohmann_json.

Cache Variables
^^^^^^^^^^^^^^^

This module uses the following cache variables:

``nlohmann_json_LIBRARY``
The location of the nlohmann_json library file.
``nlohmann_json_INCLUDE_DIR``
The location of the nlohmann_json include directory containing ``nlohmann/json.hpp``.

The cache variables should not be used by project code.
They may be set by end users to point at nlohmann_json components.
#]=======================================================================]

#-----------------------------------------------------------------------------
find_library(nlohmann_json_LIBRARY
NAMES nlohmann_json
)
mark_as_advanced(nlohmann_json_LIBRARY)

find_path(nlohmann_json_INCLUDE_DIR
NAMES nlohmann/json.hpp
)
mark_as_advanced(nlohmann_json_INCLUDE_DIR)

#-----------------------------------------------------------------------------
# Extract version number if possible.
set(_nlohmann_json_H_REGEX "^// | | |__ | | | | | | version[ \t]+\"(([0-9]+)\\.([0-9]+)\\.([0-9]+)[^\"]*)\".*$")
if(nlohmann_json_INCLUDE_DIR AND EXISTS "${nlohmann_json_INCLUDE_DIR}/nlohmann/json.hpp")
file(STRINGS "${nlohmann_json_INCLUDE_DIR}/nlohmann/json.hpp" _nlohmann_json_H REGEX "${_nlohmann_json_H_REGEX}")
else()
set(_nlohmann_json_H "")
endif()
if(_nlohmann_json_H MATCHES "${_nlohmann_json_H_REGEX}")
set(nlohmann_json_VERSION_STRING "${CMAKE_MATCH_1}")
set(nlohmann_json_VERSION_MAJOR "${CMAKE_MATCH_2}")
set(nlohmann_json_VERSION_MINOR "${CMAKE_MATCH_3}")
set(nlohmann_json_VERSION_PATCH "${CMAKE_MATCH_4}")
else()
set(nlohmann_json_VERSION_STRING "")
set(nlohmann_json_VERSION_MAJOR "")
set(nlohmann_json_VERSION_MINOR "")
set(nlohmann_json_VERSION_PATCH "")
endif()
unset(_nlohmann_json_H_REGEX)
unset(_nlohmann_json_H)

#-----------------------------------------------------------------------------
include(${CMAKE_CURRENT_LIST_DIR}/../../Modules/FindPackageHandleStandardArgs.cmake)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(nlohmann_json
FOUND_VAR nlohmann_json_FOUND
REQUIRED_VARS nlohmann_json_LIBRARY nlohmann_json_INCLUDE_DIR
VERSION_VAR nlohmann_json_VERSION_STRING
)
set(nlohmann_json_FOUND ${nlohmann_json_FOUND})

#-----------------------------------------------------------------------------
# Provide documented result variables and targets.
if(nlohmann_json_FOUND)
set(nlohmann_json_INCLUDE_DIRS ${nlohmann_json_INCLUDE_DIR})
set(nlohmann_json_LIBRARIES ${nlohmann_json_LIBRARY})
if(NOT TARGET nlohmann_json::nlohmann_json)
add_library(nlohmann_json::nlohmann_json UNKNOWN IMPORTED)
set_target_properties(nlohmann_json::nlohmann_json PROPERTIES
IMPORTED_LOCATION "${nlohmann_json_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${nlohmann_json_INCLUDE_DIRS}"
)
endif()
endif()
32 changes: 32 additions & 0 deletions Utilities/Scripts/update-cppdap.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash

set -e
set -x
shopt -s dotglob

readonly name="cppdap"
readonly ownership="cppdap Upstream <[email protected]>"
readonly subtree="Utilities/cmcppdap"
readonly repo="https://github.com/google/cppdap.git"
readonly tag="main"
readonly shortlog=false
readonly paths="
CMakeLists.txt
LICENSE
include
src
"

extract_source () {
git_archive

pushd "${extractdir}/${name}-reduced"
echo "* -whitespace" > .gitattributes
echo -e "'cppdap' is a C++11 library implementation of the Debug Adapter Protocol
version 88e8952, Dec 23, 2021\nCopyright Google LLC\n\nThis product includes software developed at Google." > NOTICE
echo -e "\ninstall(FILES NOTICE DESTINATION \${CMAKE_DOC_DIR}/cmcppdap)" >> CMakeLists.txt
sed -i 's/cmake_minimum_required(VERSION 2.8)//' CMakeLists.txt
popd
}

. "${BASH_SOURCE%/*}/update-third-party.bash"
31 changes: 31 additions & 0 deletions Utilities/Scripts/update-nlohmannjson.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash

set -e
set -x
shopt -s dotglob

readonly name="nlohmann_json"
readonly ownership="nlohmann_json Upstream <[email protected]>"
readonly subtree="Utilities/cmnlohmann_json"
readonly repo="https://github.com/nlohmann/json.git"
readonly tag="v3.11.2"
readonly shortlog=false
readonly paths="
cmake
include
single_include
CMakeLists.txt
LICENSE.MIT
nlohmann_json.natvis
"

extract_source () {
git_archive

pushd "${extractdir}/${name}-reduced"
echo "* -whitespace" >> .gitattributes
echo -e "\ninstall(FILES LICENSE.MIT DESTINATION \${CMAKE_DOC_DIR}/cmnlohmann_json)" >> CMakeLists.txt
popd
}

. "${BASH_SOURCE%/*}/update-third-party.bash"
11 changes: 11 additions & 0 deletions Utilities/cm3p/cppdap/dap.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
#pragma once

/* Use the cppdap library configured for CMake. */
#include "cmThirdParty.h"
#ifdef CMAKE_USE_SYSTEM_CPPDAP
# include <dap/dap.h> // IWYU pragma: export
#else
# include <cmcppdap/include/dap/dap.h> // IWYU pragma: export
#endif
11 changes: 11 additions & 0 deletions Utilities/cm3p/cppdap/io.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
#pragma once

/* Use the cppdap library configured for CMake. */
#include "cmThirdParty.h"
#ifdef CMAKE_USE_SYSTEM_CPPDAP
# include <dap/io.h> // IWYU pragma: export
#else
# include <cmcppdap/include/dap/io.h> // IWYU pragma: export
#endif
11 changes: 11 additions & 0 deletions Utilities/cm3p/cppdap/protocol.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
#pragma once

/* Use the cppdap library configured for CMake. */
#include "cmThirdParty.h"
#ifdef CMAKE_USE_SYSTEM_CPPDAP
# include <dap/protocol.h> // IWYU pragma: export
#else
# include <cmcppdap/include/dap/protocol.h> // IWYU pragma: export
#endif
11 changes: 11 additions & 0 deletions Utilities/cm3p/cppdap/session.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
#pragma once

/* Use the cppdap library configured for CMake. */
#include "cmThirdParty.h"
#ifdef CMAKE_USE_SYSTEM_CPPDAP
# include <dap/session.h> // IWYU pragma: export
#else
# include <cmcppdap/include/dap/session.h> // IWYU pragma: export
#endif
11 changes: 11 additions & 0 deletions Utilities/cm3p/nlohmann/json/json.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
#pragma once

/* Use the nlohmann_json library configured for CMake. */
#include "cmThirdParty.h"
#ifdef CMAKE_USE_SYSTEM_NLOHMANNJSON
# include <nlohmann/json.hpp> // IWYU pragma: export
#else
# include <cmnlohmann/include/nlohmann/json.hpp> // IWYU pragma: export
#endif
Loading