mirror of
https://github.com/polhenarejos/pico-fido
synced 2026-06-18 20:35:58 +02:00
Beautify cmake files.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
133
CMakeLists.txt
133
CMakeLists.txt
@@ -21,13 +21,27 @@ set(USB_VID 0x2E8A)
|
|||||||
set(USB_PID 0x10FE)
|
set(USB_PID 0x10FE)
|
||||||
|
|
||||||
if(ESP_PLATFORM)
|
if(ESP_PLATFORM)
|
||||||
set(DENABLE_POWER_ON_RESET 0)
|
if(NOT DEFINED ENABLE_POWER_ON_RESET)
|
||||||
set(EXTRA_COMPONENT_DIRS pico-keys-sdk/config/esp32/components src/fido)
|
set(ENABLE_POWER_ON_RESET 0)
|
||||||
|
endif()
|
||||||
|
if(NOT DEFINED ENABLE_PQC)
|
||||||
|
set(ENABLE_PQC 0)
|
||||||
|
endif()
|
||||||
|
set(EXTRA_COMPONENT_DIRS
|
||||||
|
src/fido
|
||||||
|
pico-keys-sdk/config/esp32/components/pico-keys-sdk
|
||||||
|
pico-keys-sdk/config/esp32/components/tinycbor
|
||||||
|
)
|
||||||
|
if(ENABLE_PQC)
|
||||||
|
list(APPEND EXTRA_COMPONENT_DIRS
|
||||||
|
pico-keys-sdk/config/esp32/components/mlkem512
|
||||||
|
pico-keys-sdk/config/esp32/components/mlkem768
|
||||||
|
pico-keys-sdk/config/esp32/components/mlkem1024
|
||||||
|
)
|
||||||
|
endif()
|
||||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
else()
|
else()
|
||||||
|
if(NOT ENABLE_EMULATION)
|
||||||
if(ENABLE_EMULATION)
|
|
||||||
else()
|
|
||||||
set(PICO_USE_FASTEST_SUPPORTED_CLOCK 1)
|
set(PICO_USE_FASTEST_SUPPORTED_CLOCK 1)
|
||||||
include(pico_sdk_import.cmake)
|
include(pico_sdk_import.cmake)
|
||||||
endif()
|
endif()
|
||||||
@@ -40,32 +54,31 @@ set(CMAKE_CXX_STANDARD 17)
|
|||||||
add_executable(pico_fido)
|
add_executable(pico_fido)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
include(pico-keys-sdk/cmake/options.cmake)
|
||||||
|
|
||||||
option(ENABLE_POWER_ON_RESET "Enable/disable power cycle on reset" ON)
|
option(ENABLE_POWER_ON_RESET "Enable/disable power cycle on reset" ON)
|
||||||
if(ENABLE_POWER_ON_RESET)
|
configure_bool_option(
|
||||||
add_definitions(-DENABLE_POWER_ON_RESET=1)
|
ENABLE_POWER_ON_RESET
|
||||||
message(STATUS "Power cycle on reset: \t enabled")
|
ENABLE_POWER_ON_RESET
|
||||||
else()
|
"Power cycle on reset: \t enabled"
|
||||||
add_definitions(-DENABLE_POWER_ON_RESET=0)
|
"Power cycle on reset: \t disabled"
|
||||||
message(STATUS "Power cycle on reset: \t disabled")
|
)
|
||||||
endif(ENABLE_POWER_ON_RESET)
|
|
||||||
|
|
||||||
option(ENABLE_OATH_APP "Enable/disable OATH application" ON)
|
option(ENABLE_OATH_APP "Enable/disable OATH application" ON)
|
||||||
if(ENABLE_OATH_APP)
|
configure_bool_option(
|
||||||
add_definitions(-DENABLE_OATH_APP=1)
|
ENABLE_OATH_APP
|
||||||
message(STATUS "OATH Application: \t\t enabled")
|
ENABLE_OATH_APP
|
||||||
else()
|
"OATH Application: \t\t enabled"
|
||||||
add_definitions(-DENABLE_OATH_APP=0)
|
"OATH Application: \t\t disabled"
|
||||||
message(STATUS "OATH Application: \t\t disabled")
|
)
|
||||||
endif(ENABLE_OATH_APP)
|
|
||||||
|
|
||||||
option(ENABLE_OTP_APP "Enable/disable OTP application" ON)
|
option(ENABLE_OTP_APP "Enable/disable OTP application" ON)
|
||||||
if(ENABLE_OTP_APP)
|
configure_bool_option(
|
||||||
add_definitions(-DENABLE_OTP_APP=1)
|
ENABLE_OTP_APP
|
||||||
message(STATUS "OTP Application: \t\t enabled")
|
ENABLE_OTP_APP
|
||||||
else()
|
"OTP Application: \t\t enabled"
|
||||||
add_definitions(-DENABLE_OTP_APP=0)
|
"OTP Application: \t\t disabled"
|
||||||
message(STATUS "OTP Application: \t\t disabled")
|
)
|
||||||
endif(ENABLE_OTP_APP)
|
|
||||||
|
|
||||||
if(ENABLE_OTP_APP OR ENABLE_OATH_APP)
|
if(ENABLE_OTP_APP OR ENABLE_OATH_APP)
|
||||||
set(USB_ITF_CCID 1)
|
set(USB_ITF_CCID 1)
|
||||||
@@ -81,7 +94,7 @@ if(NOT ESP_PLATFORM)
|
|||||||
set(SOURCES ${PICO_KEYS_SOURCES})
|
set(SOURCES ${PICO_KEYS_SOURCES})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(SOURCES ${SOURCES}
|
list(APPEND SOURCES
|
||||||
${CMAKE_CURRENT_LIST_DIR}/src/fido/fido.c
|
${CMAKE_CURRENT_LIST_DIR}/src/fido/fido.c
|
||||||
${CMAKE_CURRENT_LIST_DIR}/src/fido/files.c
|
${CMAKE_CURRENT_LIST_DIR}/src/fido/files.c
|
||||||
${CMAKE_CURRENT_LIST_DIR}/src/fido/kek.c
|
${CMAKE_CURRENT_LIST_DIR}/src/fido/kek.c
|
||||||
@@ -104,13 +117,15 @@ set(SOURCES ${SOURCES}
|
|||||||
${CMAKE_CURRENT_LIST_DIR}/src/fido/management.c
|
${CMAKE_CURRENT_LIST_DIR}/src/fido/management.c
|
||||||
${CMAKE_CURRENT_LIST_DIR}/src/fido/defs.c
|
${CMAKE_CURRENT_LIST_DIR}/src/fido/defs.c
|
||||||
)
|
)
|
||||||
if (${ENABLE_OATH_APP})
|
|
||||||
set(SOURCES ${SOURCES}
|
if(ENABLE_OATH_APP)
|
||||||
|
list(APPEND SOURCES
|
||||||
${CMAKE_CURRENT_LIST_DIR}/src/fido/oath.c
|
${CMAKE_CURRENT_LIST_DIR}/src/fido/oath.c
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
if (${ENABLE_OTP_APP})
|
|
||||||
set(SOURCES ${SOURCES}
|
if(ENABLE_OTP_APP)
|
||||||
|
list(APPEND SOURCES
|
||||||
${CMAKE_CURRENT_LIST_DIR}/src/fido/otp.c
|
${CMAKE_CURRENT_LIST_DIR}/src/fido/otp.c
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
@@ -119,54 +134,82 @@ SET_VERSION(ver_major ver_minor "${CMAKE_CURRENT_LIST_DIR}/src/fido/version.h" 3
|
|||||||
if(ESP_PLATFORM)
|
if(ESP_PLATFORM)
|
||||||
project(pico_fido)
|
project(pico_fido)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(INCLUDES ${INCLUDES}
|
set(INCLUDES ${INCLUDES}
|
||||||
${CMAKE_CURRENT_LIST_DIR}/src/fido
|
${CMAKE_CURRENT_LIST_DIR}/src/fido
|
||||||
)
|
)
|
||||||
|
|
||||||
if(NOT ESP_PLATFORM)
|
if(NOT ESP_PLATFORM)
|
||||||
target_sources(pico_fido PUBLIC ${SOURCES})
|
target_sources(pico_fido PUBLIC ${SOURCES})
|
||||||
target_include_directories(pico_fido PUBLIC ${INCLUDES})
|
target_include_directories(pico_fido PUBLIC ${INCLUDES})
|
||||||
|
|
||||||
target_compile_options(pico_fido PUBLIC
|
set(COMMON_COMPILE_OPTIONS
|
||||||
-Wall
|
-Wall
|
||||||
)
|
)
|
||||||
|
target_compile_options(pico_fido PRIVATE ${COMMON_COMPILE_OPTIONS})
|
||||||
|
|
||||||
if(NOT MSVC)
|
if(NOT MSVC)
|
||||||
target_compile_options(pico_fido PUBLIC
|
set(NON_MSVC_COMPILE_OPTIONS
|
||||||
-Werror
|
-Werror
|
||||||
)
|
)
|
||||||
|
target_compile_options(pico_fido PRIVATE ${NON_MSVC_COMPILE_OPTIONS})
|
||||||
|
|
||||||
string(FIND ${CMAKE_C_COMPILER} ":" COMPILER_COLON)
|
string(FIND ${CMAKE_C_COMPILER} ":" COMPILER_COLON)
|
||||||
if(${COMPILER_COLON} GREATER_EQUAL 0)
|
if(${COMPILER_COLON} GREATER_EQUAL 0)
|
||||||
target_compile_options(pico_fido PUBLIC
|
target_compile_options(pico_fido PRIVATE
|
||||||
-Wno-error=use-after-free
|
-Wno-error=use-after-free
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
endif(NOT MSVC)
|
endif()
|
||||||
|
|
||||||
if(ENABLE_EMULATION)
|
if(ENABLE_EMULATION)
|
||||||
if(NOT MSVC)
|
if(NOT MSVC)
|
||||||
target_compile_options(pico_fido PUBLIC
|
set(EMULATION_NON_MSVC_COMPILE_OPTIONS
|
||||||
-fdata-sections
|
-fdata-sections
|
||||||
-ffunction-sections
|
-ffunction-sections
|
||||||
)
|
)
|
||||||
endif(NOT MSVC)
|
target_compile_options(pico_fido PRIVATE ${EMULATION_NON_MSVC_COMPILE_OPTIONS})
|
||||||
|
endif()
|
||||||
|
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
target_link_options(pico_fido PUBLIC
|
set(EMULATION_APPLE_LINK_OPTIONS
|
||||||
-Wl,-dead_strip
|
-Wl,-dead_strip
|
||||||
)
|
)
|
||||||
|
target_link_options(pico_fido PRIVATE ${EMULATION_APPLE_LINK_OPTIONS})
|
||||||
|
|
||||||
if(DEBUG_APDU)
|
if(DEBUG_APDU)
|
||||||
target_compile_options(pico_fido PUBLIC
|
set(DEBUG_APDU_SANITIZER_OPTIONS
|
||||||
-fsanitize=address -g -O1 -fno-omit-frame-pointer)
|
-fsanitize=address
|
||||||
target_link_options(pico_fido PUBLIC
|
-g
|
||||||
-fsanitize=address -g -O1 -fno-omit-frame-pointer)
|
-O1
|
||||||
|
-fno-omit-frame-pointer
|
||||||
|
)
|
||||||
|
target_compile_options(pico_fido PRIVATE ${DEBUG_APDU_SANITIZER_OPTIONS})
|
||||||
|
target_link_options(pico_fido PRIVATE ${DEBUG_APDU_SANITIZER_OPTIONS})
|
||||||
endif()
|
endif()
|
||||||
else()
|
else()
|
||||||
target_link_options(pico_fido PUBLIC
|
set(EMULATION_NON_APPLE_LINK_OPTIONS
|
||||||
-Wl,--gc-sections
|
-Wl,--gc-sections
|
||||||
)
|
)
|
||||||
endif (APPLE)
|
target_link_options(pico_fido PRIVATE ${EMULATION_NON_APPLE_LINK_OPTIONS})
|
||||||
|
endif()
|
||||||
|
|
||||||
target_link_libraries(pico_fido PRIVATE pico_keys_sdk mbedtls pthread m)
|
target_link_libraries(pico_fido PRIVATE pico_keys_sdk mbedtls pthread m)
|
||||||
else()
|
else()
|
||||||
target_link_libraries(pico_fido PRIVATE pico_keys_sdk pico_stdlib pico_multicore hardware_flash hardware_sync hardware_adc pico_unique_id pico_aon_timer tinyusb_device tinyusb_board)
|
target_link_libraries(
|
||||||
|
pico_fido
|
||||||
|
PRIVATE
|
||||||
|
pico_keys_sdk
|
||||||
|
pico_stdlib
|
||||||
|
pico_multicore
|
||||||
|
hardware_flash
|
||||||
|
hardware_sync
|
||||||
|
hardware_adc
|
||||||
|
pico_unique_id
|
||||||
|
pico_aon_timer
|
||||||
|
tinyusb_device
|
||||||
|
tinyusb_board
|
||||||
|
)
|
||||||
pico_add_extra_outputs(${CMAKE_PROJECT_NAME})
|
pico_add_extra_outputs(${CMAKE_PROJECT_NAME})
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
Submodule pico-keys-sdk updated: 7abedc5b0e...4c88d712b4
Reference in New Issue
Block a user