Skip to content
Merged
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
7 changes: 1 addition & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@
# This is the CMake version supplied by Ubuntu 20.04.
cmake_minimum_required (VERSION 3.16.3 FATAL_ERROR)

find_program(CCACHE_PROGRAM ccache)
if(CCACHE_PROGRAM)
MESSAGE(STATUS "Enabling ccache")
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}")
endif()

project (P4C)

include(CMakeDependentOption)
Expand All @@ -31,6 +25,7 @@ set (CMAKE_CXX_STANDARD 20)
set (CMAKE_CXX_STANDARD_REQUIRED ON)

set (CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
include(ccache)
set (P4C_RUNTIME_OUTPUT_DIRECTORY bin)
set (P4C_LIBRARY_OUTPUT_DIRECTORY lib)
set (P4C_ARTIFACTS_OUTPUT_DIRECTORY share/p4c)
Expand Down
8 changes: 0 additions & 8 deletions backends/p4tools/cmake/common.cmake
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
# Common configuration across all P4Tools projects.

# Use ccache if available.
find_program(CCACHE_PROGRAM ccache)
if(CCACHE_PROGRAM)
message(STATUS "Enabling ccache")
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}")
endif()

# Helper for defining a p4tools executable target.
function(add_p4tools_executable target source)
add_executable(${target} ${source} ${ARGN})
install(TARGETS ${target} RUNTIME DESTINATION ${P4C_RUNTIME_OUTPUT_DIRECTORY})
endfunction(add_p4tools_executable)

22 changes: 22 additions & 0 deletions cmake/ccache.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# ccache integration for p4c builds.

include_guard(GLOBAL)

option(ENABLE_CCACHE "Enable ccache compiler launcher when available" ON)

if(NOT ENABLE_CCACHE)
return()
endif()

find_program(CCACHE_PROGRAM ccache)
if(NOT CCACHE_PROGRAM)
return()
endif()

message(STATUS "Enabling ccache: ${CCACHE_PROGRAM}")

foreach(LANG C CXX)
if(NOT CMAKE_${LANG}_COMPILER_LAUNCHER)
set(CMAKE_${LANG}_COMPILER_LAUNCHER "${CCACHE_PROGRAM}")
endif()
endforeach()
Loading