Skip to content

Commit eb12585

Browse files
authored
Merge pull request #7447 from Naruto/feature/enable_sccache
add ENABLE_SCCACHE option
2 parents 3a89c45 + 38dc4f2 commit eb12585

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

CMakeLists.txt

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2114,6 +2114,44 @@ else()
21142114
endif()
21152115
set(OPTION_FILE "${WOLFSSL_OUTPUT_BASE}/wolfssl/options.h")
21162116

2117+
# sccache
2118+
add_option("ENABLE_SCCACHE"
2119+
"Enable sccache (default: disabled)"
2120+
"no" "yes;no")
2121+
2122+
if (ENABLE_SCCACHE AND (NOT WOLFSSL_SCCACHE_ALREADY_SET_FLAG))
2123+
find_program(SCCACHE sccache REQUIRED)
2124+
if(SCCACHE)
2125+
message(STATUS "Enable sccache")
2126+
2127+
if(CMAKE_C_COMPILER_LAUNCHER)
2128+
set(CMAKE_C_COMPILER_LAUNCHER "${CMAKE_C_COMPILER_LAUNCHER}" "${SCCACHE}")
2129+
else()
2130+
set(CMAKE_C_COMPILER_LAUNCHER "${SCCACHE}")
2131+
endif()
2132+
if(CMAKE_CXX_COMPILER_LAUNCHER)
2133+
set(CMAKE_CXX_COMPILER_LAUNCHER "${CMAKE_CXX_COMPILER_LAUNCHER}" "${SCCACHE}")
2134+
else()
2135+
set(CMAKE_CXX_COMPILER_LAUNCHER "${SCCACHE}")
2136+
endif()
2137+
2138+
if (MSVC)
2139+
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
2140+
string(REPLACE "/Zi" "/Z7" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
2141+
string(REPLACE "/Zi" "/Z7" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
2142+
elseif(CMAKE_BUILD_TYPE STREQUAL "Release")
2143+
string(REPLACE "/Zi" "/Z7" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
2144+
string(REPLACE "/Zi" "/Z7" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
2145+
elseif(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
2146+
string(REPLACE "/Zi" "/Z7" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
2147+
string(REPLACE "/Zi" "/Z7" CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}")
2148+
endif()
2149+
endif()
2150+
set(WOLFSSL_SCCACHE_ALREADY_SET_FLAG ON)
2151+
endif()
2152+
endif()
2153+
2154+
21172155
file(REMOVE ${OPTION_FILE})
21182156

21192157
file(APPEND ${OPTION_FILE} "/* wolfssl options.h\n")

0 commit comments

Comments
 (0)