Skip to content

Commit

Permalink
Third-party build fix: #18
Browse files Browse the repository at this point in the history
  • Loading branch information
Artiom N. committed Nov 21, 2024
1 parent 5e96d5a commit 11ad1cd
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 58 deletions.
23 changes: 15 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ if (KNP_ENABLE_AVX)
# -include bits/stdc++.h
endif()

if (NOT KNP_MAINTAINER_BUILD)
if (NOT KNP_MAINTAINER_BUILD AND KNP_BUILD_AUTONOMOUS)
execute_process(COMMAND pre-commit install
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
if(ret AND NOT ret EQUAL 0)
Expand Down Expand Up @@ -224,8 +224,14 @@ if (MSVC)
endif()

if (KNP_BUILD_AUTONOMOUS)
set(CPM_SOURCE_CACHE_DEFAULT "${CMAKE_CURRENT_SOURCE_DIR}/third-party" CACHE STRING "")
set(CPM_SOURCE_CACHE "${CMAKE_CURRENT_SOURCE_DIR}/third-party" CACHE STRING "")
if (NOT CPM_SOURCE_CACHE_DEFAULT)
set(CPM_SOURCE_CACHE_DEFAULT "${CMAKE_CURRENT_SOURCE_DIR}/third-party")
endif()

if (NOT CPM_SOURCE_CACHE)
message(STATUS "Autonomous build. Setting source cached directory to \"${CPM_SOURCE_CACHE_DEFAULT}\".")
set(CPM_SOURCE_CACHE "${CPM_SOURCE_CACHE_DEFAULT}")
endif()
endif()

# Make cache variables for installation destinations.
Expand Down Expand Up @@ -304,6 +310,8 @@ add_third_party("gh:intel/pcm"
"NO_STATIC_MSVC_RUNTIME_LIBRARY ON"
"NO_ASAN ON")

include_directories("${CPM_PACKAGE_pcm_SOURCE_DIR}/src")

add_third_party("gh:gabime/[email protected]"
OPTIONS
"SPDLOG_BUILD_PIC ON"
Expand All @@ -328,11 +336,10 @@ if (KNP_BUILD_TESTS)
"INSTALL_GTEST OFF")
endif()


if (CPM_SOURCE_CACHE)
file(GLOB THIRD_PARTY_INCLUDES LIST_DIRECTORIES true "${CPM_SOURCE_CACHE}/**/include")
include_directories("${CPM_SOURCE_CACHE}" ${THIRD_PARTY_INCLUDES})
endif()
#if (CPM_SOURCE_CACHE)
# file(GLOB THIRD_PARTY_INCLUDES LIST_DIRECTORIES true "${CPM_SOURCE_CACHE}/**/include")
# include_directories("${CPM_SOURCE_CACHE}" ${THIRD_PARTY_INCLUDES})
#endif()

if (MSVC)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS FALSE)
Expand Down
1 change: 0 additions & 1 deletion cmake/CPM.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ See https://github.com/cpm-cmake/CPM.cmake for more information."
if(${CMAKE_VERSION} VERSION_LESS "3.17.0")
include(FetchContent)
endif()
return()
endif()

get_property(
Expand Down
68 changes: 34 additions & 34 deletions cmake/third-party.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,37 +14,37 @@ See the License for the specific language governing permissions and
limitations under the License.
]]

#
# CMake third-party support functions. Artiom N.(cl)2022
#

include_guard(GLOBAL)

# include(get_cpm)
include("CPM")


function(add_third_party module_name)
# add_git_submodule("${CMAKE_CURRENT_SOURCE_DIR}/third-party/${module_name}")
set(CPM_USE_LOCAL_PACKAGES ON)
if(NOT KNP_ROOT_DIR)
set(KNP_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
endif()

if(NOT "${module_name}" STREQUAL NAME)
cpm_parse_add_package_single_arg("${module_name};${ARGN}" ARGN)
# The shorthand syntax implies EXCLUDE_FROM_ALL and SYSTEM
list(GET ARGN 1 _repo_name)
get_filename_component(_repo_name ${_repo_name} NAME)
CPMADDPackage(${ARGN}
EXCLUDE_FROM_ALL YES
SYSTEM YES
SOURCE_DIR "${KNP_ROOT_DIR}/third-party/${_repo_name}")
else()
list(GET ARGN 0 _m_name)
CPMADDPackage("${module_name}" ${ARGN}
EXCLUDE_FROM_ALL YES
SYSTEM YES
SOURCE_DIR "${KNP_ROOT_DIR}/third-party/${_m_name}")
endif()
endfunction()
#
# CMake third-party support functions. Artiom N.(cl)2022
#

include_guard(GLOBAL)

# include(get_cpm)
include(CPM)


function(add_third_party module_name)
# add_git_submodule("${CMAKE_CURRENT_SOURCE_DIR}/third-party/${module_name}")
set(CPM_USE_LOCAL_PACKAGES ON)
if(NOT KNP_ROOT_DIR)
set(KNP_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
endif()

if(NOT "${module_name}" STREQUAL NAME)
cpm_parse_add_package_single_arg("${module_name};${ARGN}" ARGN)
# The shorthand syntax implies EXCLUDE_FROM_ALL and SYSTEM
list(GET ARGN 1 _repo_name)
get_filename_component(_repo_name ${_repo_name} NAME)
CPMAddPackage(${ARGN}
EXCLUDE_FROM_ALL YES
SYSTEM YES)
# SOURCE_DIR "${KNP_ROOT_DIR}/third-party/${_repo_name}")
else()
list(GET ARGN 0 _m_name)
CPMAddPackage("${module_name}" ${ARGN}
EXCLUDE_FROM_ALL YES
SYSTEM YES)
# SOURCE_DIR "${KNP_ROOT_DIR}/third-party/${_m_name}")
endif()
endfunction()
2 changes: 1 addition & 1 deletion knp/devices-library/impl/cpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# pragma clang diagnostic ignored "-Wdocumentation"
#endif

#include <pcm/src/cpucounters.h>
#include <cpucounters.h>

#if defined(__clang__)
# pragma clang diagnostic pop
Expand Down
2 changes: 1 addition & 1 deletion knp/devices-library/impl/cpu_power.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

#include "cpu_power.h"

#include <pcm/src/utils.h>
#include <spdlog/spdlog.h>
#include <utils.h>

#include <exception>
#include <utility>
Expand Down
26 changes: 13 additions & 13 deletions knp/devices-library/impl/cpu_power.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
* @kaspersky_support Artiom N.
* @date 20.02.2023
* @license Apache 2.0
* @copyright © 2024 AO Kaspersky Lab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* @copyright © 2024 AO Kaspersky Lab
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

Expand All @@ -28,7 +28,7 @@
# pragma clang diagnostic ignored "-Wdocumentation"
#endif

#include <pcm/src/cpucounters.h>
#include <cpucounters.h>

#if defined(__clang__)
# pragma clang diagnostic pop
Expand Down

0 comments on commit 11ad1cd

Please sign in to comment.