Skip to content

Commit

Permalink
try ccache for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
huangminghuang committed Sep 4, 2024
1 parent f5cd2c7 commit 29846b5
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,6 @@ project(hpp_proto
VERSION 0.1.0
LANGUAGES CXX)

if(CMAKE_CXX_COMPILER_LAUNCHER STREQUAL "ccache")
find_program(CCACHE_PROGRAM ccache)

if(CCACHE_PROGRAM)
message(STATUS "Found ccache: ${CCACHE_PROGRAM}")
else()
message(WARNING "ccache Not Found")
endif()
endif()

set(CMAKE_CXX_STANDARD 20) # requires for compiling is_utf
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
Expand Down Expand Up @@ -49,6 +39,28 @@ if(HPP_PROTO_ENABLE_SANITIZER)
endif()
endif()

if (CMAKE_GENERATOR MATCHES "Visual Studio")
find_program(ccache_exe ccache)
if(ccache_exe)
file(COPY_FILE
${ccache_exe} ${CMAKE_BINARY_DIR}/cl.exe
ONLY_IF_DIFFERENT)

# By default Visual Studio generators will use /Zi which is not compatible
# with ccache, so tell Visual Studio to use /Z7 instead.
message(STATUS "Setting MSVC debug information format to 'Embedded'")
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<$<CONFIG:Debug,RelWithDebInfo>:Embedded>")

set(CMAKE_VS_GLOBALS
"CLToolExe=cl.exe"
"CLToolPath=${CMAKE_BINARY_DIR}"
"TrackFileAccess=false"
"UseMultiToolTask=true"
"DebugInformationFormat=OldStyle"
)
endif()
endif()

include(third-party.cmake)

add_library(libhpp_proto INTERFACE)
Expand Down

0 comments on commit 29846b5

Please sign in to comment.