Skip to content

Commit 4d9d12d

Browse files
authored
Expose add_enclave_library_c in ccf_app.cmake (#1073)
1 parent f402604 commit 4d9d12d

File tree

3 files changed

+24
-18
lines changed

3 files changed

+24
-18
lines changed

cmake/ccf_app.cmake

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,3 +167,12 @@ function(add_ccf_app name)
167167
endif()
168168
endif()
169169
endfunction()
170+
171+
# Convenience wrapper to build C-libraries that can be linked in enclave, ie. in
172+
# a CCF application.
173+
function(add_enclave_library_c name files)
174+
add_library(${name} STATIC ${files})
175+
target_compile_options(${name} PRIVATE -nostdinc)
176+
target_link_libraries(${name} PRIVATE openenclave::oelibc)
177+
set_property(TARGET ${name} PROPERTY POSITION_INDEPENDENT_CODE ON)
178+
endfunction()

cmake/common.cmake

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,6 @@ else()
2222
unset(NODES)
2323
endif()
2424

25-
option(COLORED_OUTPUT "Always produce ANSI-colored output (Clang only)." TRUE)
26-
27-
if(${COLORED_OUTPUT})
28-
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
29-
add_compile_options(-fcolor-diagnostics)
30-
endif()
31-
endif()
32-
3325
option(VERBOSE_LOGGING "Enable verbose logging" OFF)
3426
set(TEST_HOST_LOGGING_LEVEL "info")
3527
if(VERBOSE_LOGGING)
@@ -165,13 +157,6 @@ set(HTTP_PARSER_SOURCES ${CCF_DIR}/3rdparty/http-parser/http_parser.c)
165157

166158
find_library(CRYPTO_LIBRARY crypto)
167159

168-
function(add_enclave_library_c name files)
169-
add_library(${name} STATIC ${files})
170-
target_compile_options(${name} PRIVATE -nostdinc)
171-
target_link_libraries(${name} PRIVATE openenclave::oelibc)
172-
set_property(TARGET ${name} PROPERTY POSITION_INDEPENDENT_CODE ON)
173-
endfunction()
174-
175160
include(${CCF_DIR}/cmake/crypto.cmake)
176161
include(${CCF_DIR}/cmake/secp256k1.cmake)
177162
include(${CCF_DIR}/cmake/quickjs.cmake)
@@ -192,7 +177,11 @@ function(add_unit_test name)
192177
add_san(${name})
193178

194179
add_test(NAME ${name} COMMAND ${CCF_DIR}/tests/unit_test_wrapper.sh ${name})
195-
set_property(TEST ${name} APPEND PROPERTY LABELS unit_test)
180+
set_property(
181+
TEST ${name}
182+
APPEND
183+
PROPERTY LABELS unit_test
184+
)
196185
endfunction()
197186

198187
if("sgx" IN_LIST COMPILE_TARGETS)

cmake/preproject.cmake

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
# Licensed under the Apache 2.0 License.
33

44
# Note: this needs to be done before project(), otherwise CMAKE_*_COMPILER is
5-
# already set by CMake If the user has not expressed any choice, we attempt to
5+
# already set by CMake. If the user has not expressed any choice, we attempt to
66
# default to Clang >= 7 If they have expressed even a partial choice, the usual
7-
# CMake selection logic applies If we cannot find both a suitable clang and a
7+
# CMake selection logic applies. If we cannot find both a suitable clang and a
88
# suitable clang++, the usual CMake selection logic applies
99
if((NOT CMAKE_C_COMPILER)
1010
AND (NOT CMAKE_CXX_COMPILER)
@@ -53,4 +53,12 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
5353
)
5454
endif()
5555

56+
option(COLORED_OUTPUT "Always produce ANSI-colored output (Clang only)." TRUE)
57+
58+
if(${COLORED_OUTPUT})
59+
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
60+
add_compile_options(-fcolor-diagnostics)
61+
endif()
62+
endif()
63+
5664
set(CMAKE_CXX_STANDARD 17)

0 commit comments

Comments
 (0)