From 2031d063b56a6b1efce2a9e4f8128618fad04659 Mon Sep 17 00:00:00 2001 From: Jack Humbert Date: Sun, 2 Apr 2023 11:20:49 -0400 Subject: [PATCH] split up functions/scripts a bit. downloads avr-gcc --- .gitignore | 3 + CMakeLists.txt | 94 +++++++++++---------------- cmake/AddKeyboard.cmake | 46 +++++++++++++ cmake/FindLufa.cmake | 23 +++++++ cmake/FindToolchain.cmake | 62 ++++++++++++++++++ cmake/GetAVR-GCC.cmake | 24 +++++++ cmake/UpdateSubmodule.cmake | 22 +++++++ cmake/features/backlight.cmake | 28 ++++++++ cmake/features/oled.cmake | 13 ++++ keyboards/CMakeLists.txt | 12 ++++ platforms/avr/toolchain.cmake | 44 +------------ tmk_core/protocol/lufa/CMakeLists.txt | 65 ++---------------- 12 files changed, 277 insertions(+), 159 deletions(-) create mode 100644 cmake/AddKeyboard.cmake create mode 100644 cmake/FindLufa.cmake create mode 100644 cmake/FindToolchain.cmake create mode 100644 cmake/GetAVR-GCC.cmake create mode 100644 cmake/UpdateSubmodule.cmake create mode 100644 cmake/features/backlight.cmake create mode 100644 cmake/features/oled.cmake create mode 100644 keyboards/CMakeLists.txt diff --git a/.gitignore b/.gitignore index 4909f67406b..09108487a4a 100644 --- a/.gitignore +++ b/.gitignore @@ -55,6 +55,9 @@ cmake-build-debug # CMakeLists.txt *.pdf +# cmake toolchain downloads +toolchains + # Let these ones be user specific, since we have so many different configurations *.code-workspace .stfolder diff --git a/CMakeLists.txt b/CMakeLists.txt index 1e55e89f92d..94b423f9fb1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,9 @@ cmake_minimum_required(VERSION 3.3) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") + +include(UpdateSubmodule) + macro(add_qmk_executable _) endmacro(add_qmk_executable) @@ -7,33 +11,7 @@ if(NOT DEFINED QMK_KEYBOARD) project(qmk_firmware) -include(ExternalProject) - -macro(add_keyboard KEYBOARD_CMAKE) - get_filename_component(KEYBOARD_FULL_DIRECTORY "${KEYBOARD_CMAKE}" DIRECTORY) - file(RELATIVE_PATH KEYBOARD_FOLDER "${CMAKE_SOURCE_DIR}/keyboards" "${KEYBOARD_FULL_DIRECTORY}") - string(REPLACE "/" "." KEYBOARD_NAME ${KEYBOARD_FOLDER}) - ExternalProject_Add(${KEYBOARD_NAME} - SOURCE_DIR ${CMAKE_SOURCE_DIR} - TMP_DIR ${CMAKE_SOURCE_DIR}/build - INSTALL_COMMAND cmake -E echo "No install needed" - CMAKE_GENERATOR "Unix Makefiles" - CMAKE_ARGS - -DCMAKE_TOOLCHAIN_FILE=${CMAKE_CURRENT_SOURCE_DIR}/platforms/avr/toolchain.cmake - -DQMK_KEYBOARD=${KEYBOARD_NAME} - -DQMK_KEYBOARD_FOLDER=${KEYBOARD_FOLDER} - ) -endmacro(add_keyboard) - -if(DEFINED QMK_KEYBOARD_FOLDER) - add_keyboard(${CMAKE_SOURCE_DIR}/keyboards/${QMK_KEYBOARD_FOLDER}/CMakeFiles.txt) -endif() - -file(GLOB_RECURSE KEYBOARDS keyboards/**/CMakeLists.txt) - -foreach(KEYBOARD_CMAKE ${KEYBOARDS}) - add_keyboard(${KEYBOARD_CMAKE}) -endforeach() +add_subdirectory(keyboards) else() @@ -47,31 +25,40 @@ while(NOT ${QMK_KEYBOARD_CURRENT_FOLDER} STREQUAL "") get_filename_component(QMK_KEYBOARD_CURRENT_FOLDER ${QMK_KEYBOARD_CURRENT_FOLDER} DIRECTORY) endwhile() -file(READ keyboards/${QMK_KEYBOARD_FOLDER}/info.json JSON_STRING) -string(JSON KEYBOARD_NAME GET ${JSON_STRING} keyboard_name) -string(JSON MANUFACTURER GET ${JSON_STRING} manufacturer) -string(JSON QMK_MCU GET ${JSON_STRING} processor) -string(JSON VENDOR_ID GET ${JSON_STRING} usb vid) -string(JSON PRODUCT_ID GET ${JSON_STRING} usb pid) -string(JSON DEVICE_VER GET ${JSON_STRING} usb device_version) +# would be nice to also do validation here +file(READ keyboards/${QMK_KEYBOARD_FOLDER}/info.json QMK_KEYBOARD_INFO_JSON_STRING) +string(JSON KEYBOARD_NAME GET ${QMK_KEYBOARD_INFO_JSON_STRING} keyboard_name) +string(JSON MANUFACTURER GET ${QMK_KEYBOARD_INFO_JSON_STRING} manufacturer) +string(JSON QMK_MCU GET ${QMK_KEYBOARD_INFO_JSON_STRING} processor) +string(JSON VENDOR_ID GET ${QMK_KEYBOARD_INFO_JSON_STRING} usb vid) +string(JSON PRODUCT_ID GET ${QMK_KEYBOARD_INFO_JSON_STRING} usb pid) +string(JSON DEVICE_VER GET ${QMK_KEYBOARD_INFO_JSON_STRING} usb device_version) foreach(FOLDER ${QMK_KEYBOARD_FOLDERS}) include_directories(${CMAKE_SOURCE_DIR}/keyboards/${FOLDER}) + # assuming every keyboard has a config at some level if(EXISTS ${CMAKE_SOURCE_DIR}/keyboards/${FOLDER}/config.h) list(APPEND QMK_KEYBOARD_CONFIG_HS "${CMAKE_SOURCE_DIR}/keyboards/${FOLDER}/config.h") endif() + # assuming every keyboard has a default/keymap.c at some level if(EXISTS ${CMAKE_SOURCE_DIR}/keyboards/${FOLDER}/keymaps/default/keymap.c) list(APPEND QMK_KEYBOARD_KEYMAPS "${CMAKE_SOURCE_DIR}/keyboards/${FOLDER}/keymaps/default/keymap.c") endif() - # not sure if merging is needed, since info.json is required iirc + get_filename_component(LAST_PART ${FOLDER} NAME) + # assuming every keyboard has a header.h at some level + if(EXISTS ${CMAKE_SOURCE_DIR}/keyboards/${FOLDER}/${LAST_PART}.h) + # use just the filename, since the folder is already in our include path (maybe it should only be the base keyboard folder?) + list(APPEND QMK_KEYBOARD_HEADERS "${LAST_PART}.h") + endif() + # not sure if merging is needed, since info.json is required per level? iirc # if(EXISTS keyboards/${FOLDER}/info.json) - # file(READ keyboards/${FOLDER}/info.json JSON_STRING) - # string(JSON KEYBOARD_NAME GET ${JSON_STRING} keyboard_name) - # string(JSON MANUFACTURER GET ${JSON_STRING} manufacturer) - # string(JSON QMK_MCU GET ${JSON_STRING} processor) - # string(JSON VENDOR_ID GET ${JSON_STRING} usb vid) - # string(JSON PRODUCT_ID GET ${JSON_STRING} usb pid) - # string(JSON DEVICE_VER GET ${JSON_STRING} usb device_version) + # file(READ keyboards/${FOLDER}/info.json QMK_KEYBOARD_INFO_JSON_STRING) + # string(JSON KEYBOARD_NAME GET ${QMK_KEYBOARD_INFO_JSON_STRING} keyboard_name) + # string(JSON MANUFACTURER GET ${QMK_KEYBOARD_INFO_JSON_STRING} manufacturer) + # string(JSON QMK_MCU GET ${QMK_KEYBOARD_INFO_JSON_STRING} processor) + # string(JSON VENDOR_ID GET ${QMK_KEYBOARD_INFO_JSON_STRING} usb vid) + # string(JSON PRODUCT_ID GET ${QMK_KEYBOARD_INFO_JSON_STRING} usb pid) + # string(JSON DEVICE_VER GET ${QMK_KEYBOARD_INFO_JSON_STRING} usb device_version) # endif() endforeach() @@ -79,9 +66,13 @@ if(NOT DEFINED QMK_KEYBOARD_KEYMAPS) message(FATAL_ERROR "Keymap not found") endif() -list(GET QMK_KEYBOARD_FOLDERS 0 QMK_KEYBOARD_BASE_FOLDER) +if(NOT DEFINED QMK_KEYBOARD_HEADERS) + message(FATAL_ERROR "Header not found") +endif() + +# list(GET QMK_KEYBOARD_FOLDERS 0 QMK_KEYBOARD_BASE_FOLDER) list(GET QMK_KEYBOARD_KEYMAPS 0 QMK_KEYBOARD_KEYMAP) -list(GET QMK_KEYBOARD_FOLDER_PARTS -1 QMK_KEYBOARD_FOLDER_LAST_PART) +list(GET QMK_KEYBOARD_HEADERS 0 QMK_KEYBOARD_HEADER) project(${QMK_KEYBOARD} LANGUAGES C CXX ASM @@ -93,7 +84,6 @@ set(VERSION_MINOR ${CMAKE_MATCH_2}) set(VERSION_PATCH ${CMAKE_MATCH_3}) math(EXPR VERSION_C_EVAL "${VERSION_MAJOR} * 10000 + ${VERSION_MINOR} * 100 + ${VERSION_PATCH}" OUTPUT_FORMAT HEXADECIMAL) - add_compile_options( -include ${QMK_KEYBOARD_CONFIG_HS} -mmcu=${QMK_MCU} @@ -104,7 +94,7 @@ add_link_options( ) add_compile_definitions( - QMK_KEYBOARD_H="${QMK_KEYBOARD_FOLDER_LAST_PART}.h" + QMK_KEYBOARD_H="${QMK_KEYBOARD_HEADER}" KEYMAP_C="${QMK_KEYBOARD_KEYMAP}" MATRIX_ROWS=6 MATRIX_COLS=15 @@ -119,16 +109,8 @@ add_subdirectory(quantum) add_subdirectory(platforms) add_subdirectory(tmk_core/protocol) -# option(OLED_ENABLE "" TRUE) -# if(${OLED_ENABLE}) -# target_sources(quantum PUBLIC -# ${CMAKE_SOURCE_DIR}/drivers/oled/ssd1306_sh1106.c -# ${CMAKE_SOURCE_DIR}/platforms/${CMAKE_SYSTEM_PROCESSOR}/drivers/i2c_master.c) -# add_compile_definitions(OLED_ENABLE) -# target_include_directories(quantum PUBLIC ${CMAKE_SOURCE_DIR}/drivers) -# target_include_directories(quantum PUBLIC ${CMAKE_SOURCE_DIR}/drivers/oled) -# target_include_directories(quantum PUBLIC ${CMAKE_SOURCE_DIR}/platforms/${CMAKE_SYSTEM_PROCESSOR}/drivers) -# endif() +include(features/oled) +include(features/backlight) if(EXISTS keyboards/${QMK_KEYBOARD_FOLDER}/CMakeLists.txt) add_subdirectory(keyboards/${QMK_KEYBOARD_FOLDER}) diff --git a/cmake/AddKeyboard.cmake b/cmake/AddKeyboard.cmake new file mode 100644 index 00000000000..6b8c7ed4741 --- /dev/null +++ b/cmake/AddKeyboard.cmake @@ -0,0 +1,46 @@ +macro(add_keyboard KEYBOARD_CMAKE) + get_filename_component(KEYBOARD_FULL_DIRECTORY "${KEYBOARD_CMAKE}" DIRECTORY) + + # find the right toolchain + file(READ ${KEYBOARD_FULL_DIRECTORY}/info.json JSON_STRING) + string(JSON PROCESSOR GET ${JSON_STRING} processor) + if(${PROCESSOR} MATCHES "^at.*") + set(PLATFORM "avr") + # find_package(avr-gcc) + elseif( + ${PROCESSOR} MATCHES "^STM.*" OR + ${PROCESSOR} MATCHES "^WB32.*" OR + ${PROCESSOR} MATCHES "^MK.*" OR + ${PROCESSOR} MATCHES "RP2040" OR + ${PROCESSOR} MATCHES "^GD32.*") + set(PLATFORM "chibios") + endif() + if(NOT DEFINED PLATFORM) + message(FATAL_ERROR "Could not find platform for ${KEYBOARD_FULL_DIRECTORY}") + endif() + + include(FindToolChain) + find_toolchain() + + file(RELATIVE_PATH KEYBOARD_FOLDER "${CMAKE_SOURCE_DIR}/keyboards" "${KEYBOARD_FULL_DIRECTORY}") + string(REPLACE "/" "." KEYBOARD_NAME ${KEYBOARD_FOLDER}) + ExternalProject_Add(${KEYBOARD_NAME} + SOURCE_DIR ${CMAKE_SOURCE_DIR} + PREFIX ${CMAKE_SOURCE_DIR}/build/keyboards/${KEYBOARD_FOLDER} + TMP_DIR ${CMAKE_SOURCE_DIR}/build/keyboards/${KEYBOARD_FOLDER}/tmp + DOWNLOAD_DIR ${CMAKE_SOURCE_DIR}/build/keyboards/${KEYBOARD_FOLDER}/Download + BINARY_DIR ${CMAKE_SOURCE_DIR}/build/keyboards/${KEYBOARD_FOLDER}/Build + STAMP_DIR ${CMAKE_SOURCE_DIR}/build/keyboards/${KEYBOARD_FOLDER}/Stamp + LOG_DIR ${CMAKE_SOURCE_DIR}/build/keyboards/${KEYBOARD_FOLDER}/Log + INSTALL_DIR ${CMAKE_SOURCE_DIR}/build/keyboards/${KEYBOARD_FOLDER}/Install + INSTALL_COMMAND cmake -E echo "No install needed" + # this seems to work well for all systems so far - not sure if it'd be useful to customize + CMAKE_GENERATOR "Unix Makefiles" + CMAKE_ARGS + -DCMAKE_TOOLCHAIN_FILE=${CMAKE_SOURCE_DIR}/platforms/${PLATFORM}/toolchain.cmake + -DTOOLCHAIN_ROOT=${TOOLCHAIN_ROOT} + -DMAKE_ROOT=${MAKE_ROOT} + -DQMK_KEYBOARD=${KEYBOARD_NAME} + -DQMK_KEYBOARD_FOLDER=${KEYBOARD_FOLDER} + ) +endmacro(add_keyboard) \ No newline at end of file diff --git a/cmake/FindLufa.cmake b/cmake/FindLufa.cmake new file mode 100644 index 00000000000..80f04e24ce1 --- /dev/null +++ b/cmake/FindLufa.cmake @@ -0,0 +1,23 @@ +include(UpdateSubmodule) +update_submodule(lib/lufa) +set(LUFA_PATH ${CMAKE_SOURCE_DIR}/lib/lufa) +set(LUFA_ROOT_PATH ${LUFA_PATH}/LUFA) +add_library(lufa + ${LUFA_ROOT_PATH}/Drivers/USB/Core/${ARCH}/USBController_${ARCH}.c + ${LUFA_ROOT_PATH}/Drivers/USB/Core/${ARCH}/USBInterrupt_${ARCH}.c + ${LUFA_ROOT_PATH}/Drivers/USB/Core/ConfigDescriptors.c + ${LUFA_ROOT_PATH}/Drivers/USB/Core/Events.c + ${LUFA_ROOT_PATH}/Drivers/USB/Core/USBTask.c + ${LUFA_ROOT_PATH}/Drivers/USB/Class/Common/HIDParser.c + + ${LUFA_ROOT_PATH}/Drivers/USB/Core/${ARCH}/Host_${ARCH}.c + ${LUFA_ROOT_PATH}/Drivers/USB/Core/${ARCH}/Pipe_${ARCH}.c + ${LUFA_ROOT_PATH}/Drivers/USB/Core/${ARCH}/PipeStream_${ARCH}.c + ${LUFA_ROOT_PATH}/Drivers/USB/Core/HostStandardReq.c + + ${LUFA_ROOT_PATH}/Drivers/USB/Core/${ARCH}/Device_${ARCH}.c + ${LUFA_ROOT_PATH}/Drivers/USB/Core/${ARCH}/Endpoint_${ARCH}.c + ${LUFA_ROOT_PATH}/Drivers/USB/Core/${ARCH}/EndpointStream_${ARCH}.c + ${LUFA_ROOT_PATH}/Drivers/USB/Core/DeviceStandardReq.c +) +target_include_directories(lufa PUBLIC ${LUFA_PATH}) \ No newline at end of file diff --git a/cmake/FindToolchain.cmake b/cmake/FindToolchain.cmake new file mode 100644 index 00000000000..cc1d426dcaf --- /dev/null +++ b/cmake/FindToolchain.cmake @@ -0,0 +1,62 @@ +macro(find_gcc TRIPLE) +if(UNIX) + set(OS_SUFFIX "") + find_path(TOOLCHAIN_ROOT + NAMES + ${TRIPLE}-gcc${OS_SUFFIX} + PATHS + "${CMAKE_SOURCE_DIR}/toolchains/avr-gcc/avr-gcc-12.1.0-x64-linux/bin/" + /usr/bin/ + /usr/local/bin + /bin/ + $ENV{AVR_ROOT} + ) + find_path(MAKE_ROOT + NAMES + make${OS_SUFFIX} + PATHS + "${CMAKE_SOURCE_DIR}/toolchains/avr-gcc/avr-gcc-12.1.0-x64-linux/bin/" + /usr/bin/ + /usr/local/bin + /bin/ + $ENV{AVR_ROOT} + ) +elseif(WIN32) + set(OS_SUFFIX ".exe") + find_path(TOOLCHAIN_ROOT + NAMES + ${TRIPLE}-gcc${OS_SUFFIX} + PATHS + "${CMAKE_SOURCE_DIR}/toolchains/avr-gcc/avr-gcc-12.1.0-x64-windows/bin/" + "C:/Users/Jack/Downloads/avr-gcc-12.1.0-x64-windows/bin/" + $ENV{AVR_ROOT} + ) + find_path(MAKE_ROOT + NAMES + make${OS_SUFFIX} + PATHS + "${CMAKE_SOURCE_DIR}/toolchains/avr-gcc/avr-gcc-12.1.0-x64-windows/bin/" + "C:/Users/Jack/Downloads/avr-gcc-12.1.0-x64-windows/bin/" + $ENV{AVR_ROOT} + ) +else(UNIX) + message(FATAL_ERROR "toolchain not supported on this OS") +endif(UNIX) +endmacro(find_gcc) + +macro(find_toolchain) +find_gcc(avr) + +if(NOT TOOLCHAIN_ROOT) + include(GetAVR-GCC) + find_gcc(avr) +endif(NOT TOOLCHAIN_ROOT) + +if(NOT TOOLCHAIN_ROOT) + message(FATAL_ERROR "Toolchain root could not be found!!!") +endif(NOT TOOLCHAIN_ROOT) + +message("Found toolchain: ${TOOLCHAIN_ROOT}") +message("Found make: ${MAKE_ROOT}") + +endmacro() \ No newline at end of file diff --git a/cmake/GetAVR-GCC.cmake b/cmake/GetAVR-GCC.cmake new file mode 100644 index 00000000000..f7edc7d6c0c --- /dev/null +++ b/cmake/GetAVR-GCC.cmake @@ -0,0 +1,24 @@ +message("Downloading avr-gcc") +if(WIN32) +file(DOWNLOAD + https://github.com/ZakKemble/avr-gcc-build/releases/download/v12.1.0-1/avr-gcc-12.1.0-x64-windows.zip + ${CMAKE_SOURCE_DIR}/toolchains/downloads/avr-gcc-x64-windows.zip + EXPECTED_HASH SHA256=e921a964fdeaedbe963352d0f26c6520a0a3eb8effc6ff232f3824b06c4ea0e2 + SHOW_PROGRESS TRUE +) +file(ARCHIVE_EXTRACT + INPUT ${CMAKE_SOURCE_DIR}/toolchains/downloads/avr-gcc-x64-windows.zip + DESTINATION ${CMAKE_SOURCE_DIR}/toolchains/ +) +elseif(UNIX) +file(DOWNLOAD + https://github.com/ZakKemble/avr-gcc-build/releases/download/v12.1.0-1/avr-gcc-12.1.0-x64-linux.tar.bz2 + ${CMAKE_SOURCE_DIR}/toolchains/downloads/avr-gcc-x64-linux.tar.bz2 + EXPECTED_HASH SHA256=feb034f4b85237032da8bac1f03765af5ebc4a8939b69bed57ff31bc482ca1a6 + SHOW_PROGRESS TRUE +) +file(ARCHIVE_EXTRACT + INPUT ${CMAKE_SOURCE_DIR}/toolchains/downloads/avr-gcc-x64-linux.tar.bz2 + DESTINATION ${CMAKE_SOURCE_DIR}/toolchains/ +) +endif() \ No newline at end of file diff --git a/cmake/UpdateSubmodule.cmake b/cmake/UpdateSubmodule.cmake new file mode 100644 index 00000000000..dede02c885d --- /dev/null +++ b/cmake/UpdateSubmodule.cmake @@ -0,0 +1,22 @@ +# can be passed a relative path (to CMAKE_SOURCE_DIR) to update/checkout that submodule +macro(update_submodule SUBMODULE) + find_package(Git QUIET) + if(GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR}/.git") + option(GIT_SUBMODULE "Check submodules during build" ON) + if(GIT_SUBMODULE) + message(STATUS "Updating submoudle ${SUBMODULE}") + execute_process(COMMAND ${GIT_EXECUTABLE} submodule update ${SUBMODULE} + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + RESULT_VARIABLE GIT_SUBMOD_RESULT) + if(NOT GIT_SUBMOD_RESULT EQUAL "0") + message(FATAL_ERROR "git submodule update ${SUBMODULE} failed with ${GIT_SUBMOD_RESULT}, please checkout submodules") + endif() + endif() + else() + message("Git not found - skipping submodule update") + endif() + + if(NOT EXISTS "${CMAKE_SOURCE_DIR}/${SUBMODULE}/.git") + message(FATAL_ERROR "The submodule was not downloaded! GIT_SUBMODULE was turned off or failed. Please update submodules and try again.") + endif() +endmacro() \ No newline at end of file diff --git a/cmake/features/backlight.cmake b/cmake/features/backlight.cmake new file mode 100644 index 00000000000..b4545d77860 --- /dev/null +++ b/cmake/features/backlight.cmake @@ -0,0 +1,28 @@ +option(BACKLIGHT_ENABLE "" TRUE) +set(BACKLIGHT_DRIVER "pwm" CACHE STRING "Backlight driver") +set_property(CACHE BACKLIGHT_DRIVER PROPERTY STRINGS pwm timer software custom) + +if(${BACKLIGHT_ENABLE}) + add_library(backlight + quantum/backlight/backlight.c + quantum/process_keycode/process_backlight.c + ) + string(JSON BACKLIGHT_PIN GET ${QMK_KEYBOARD_INFO_JSON_STRING} backlight pin) + add_compile_definitions( + BACKLIGHT_ENABLE + BACKLIGHT_PIN=${BACKLIGHT_PIN} + ) + if(${BACKLIGHT_DRIVER} STREQUAL "custom") + add_compile_definitions(BACKLIGHT_CUSTOM_DRIVER) + else() + target_sources(backlight PRIVATE quantum/backlight/backlight_driver_common.c) + if(${BACKLIGHT_DRIVER} STREQUAL "pwm") + target_sources(backlight PRIVATE quantum/backlight/backlight_${CMAKE_SYSTEM_PROCESSOR}.c) + else() + target_sources(backlight PRIVATE quantum/backlight/backlight_${BACKLIGHT_DRIVER}.c) + endif() + endif() + target_include_directories(backlight PUBLIC quantum/backlight) + target_include_directories(quantum PUBLIC quantum/backlight) + target_link_libraries(backlight PUBLIC quantum) +endif() diff --git a/cmake/features/oled.cmake b/cmake/features/oled.cmake new file mode 100644 index 00000000000..e84b72d2335 --- /dev/null +++ b/cmake/features/oled.cmake @@ -0,0 +1,13 @@ +option(OLED_ENABLE "" TRUE) +if(${OLED_ENABLE}) + add_library(oled + drivers/oled/ssd1306_sh1106.c + platforms/${CMAKE_SYSTEM_PROCESSOR}/drivers/i2c_master.c) + add_compile_definitions(OLED_ENABLE) + target_include_directories(oled PUBLIC drivers) + target_include_directories(quantum PUBLIC drivers/oled) + target_include_directories(oled PUBLIC drivers/oled) + target_include_directories(oled PUBLIC platforms/${CMAKE_SYSTEM_PROCESSOR}/drivers) + target_link_libraries(oled PUBLIC quantum) + target_link_libraries(oled PUBLIC platform_avr) +endif() diff --git a/keyboards/CMakeLists.txt b/keyboards/CMakeLists.txt new file mode 100644 index 00000000000..5c1cbdf5dc0 --- /dev/null +++ b/keyboards/CMakeLists.txt @@ -0,0 +1,12 @@ +include(ExternalProject) +include(AddKeyboard) + +if(DEFINED QMK_KEYBOARD_FOLDER) + add_keyboard(${CMAKE_SOURCE_DIR}/keyboards/${QMK_KEYBOARD_FOLDER}/CMakeFiles.txt) +endif() + +file(GLOB_RECURSE KEYBOARDS **/CMakeLists.txt) + +foreach(KEYBOARD_CMAKE ${KEYBOARDS}) + add_keyboard(${KEYBOARD_CMAKE}) +endforeach() \ No newline at end of file diff --git a/platforms/avr/toolchain.cmake b/platforms/avr/toolchain.cmake index 9a6e31b70ee..cf2499002cf 100644 --- a/platforms/avr/toolchain.cmake +++ b/platforms/avr/toolchain.cmake @@ -6,52 +6,12 @@ set(TRIPLE "avr") -# find the toolchain root directory - if(UNIX) set(OS_SUFFIX "") - find_path(TOOLCHAIN_ROOT - NAMES - ${TRIPLE}-gcc${OS_SUFFIX} - PATHS - /usr/bin/ - /usr/local/bin - /bin/ - $ENV{AVR_ROOT} - ) - find_path(MAKE_ROOT - NAMES - make${OS_SUFFIX} - PATHS - /usr/bin/ - /usr/local/bin - /bin/ - $ENV{AVR_ROOT} - ) elseif(WIN32) set(OS_SUFFIX ".exe") - find_path(TOOLCHAIN_ROOT - NAMES - ${TRIPLE}-gcc${OS_SUFFIX} - PATHS - "C:/Users/Jack/Downloads/avr-gcc-12.1.0-x64-windows/bin/" - $ENV{AVR_ROOT} - ) - set(OS_SUFFIX ".exe") - find_path(MAKE_ROOT - NAMES - make${OS_SUFFIX} - PATHS - "C:/Users/Jack/Downloads/avr-gcc-12.1.0-x64-windows/bin/" - $ENV{AVR_ROOT} - ) -else(UNIX) - message(FATAL_ERROR "toolchain not supported on this OS") -endif(UNIX) +endif() -if(NOT TOOLCHAIN_ROOT) - message(FATAL_ERROR "Toolchain root could not be found!!!") -endif(NOT TOOLCHAIN_ROOT) # setup the AVR compiler variables @@ -117,7 +77,7 @@ add_compile_definitions( # LTO_ENABLE ) -include_directories("C:/Users/Jack/Downloads/avr-gcc-12.1.0-x64-windows/avr/include") +# include_directories("C:/Users/Jack/Downloads/avr-gcc-12.1.0-x64-windows/avr/include") macro(add_qmk_executable target_name) diff --git a/tmk_core/protocol/lufa/CMakeLists.txt b/tmk_core/protocol/lufa/CMakeLists.txt index 170b4d04f46..84b67e83536 100644 --- a/tmk_core/protocol/lufa/CMakeLists.txt +++ b/tmk_core/protocol/lufa/CMakeLists.txt @@ -1,4 +1,3 @@ -set(LUFA_PATH ${CMAKE_SOURCE_DIR}/lib/lufa) set(ARCH AVR8) set(USE_STATIC_OPTIONS "(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)") @@ -20,65 +19,9 @@ add_library(tmk_core_protocol_lufa usb_util.c ) +find_package(lufa REQUIRED) + target_include_directories(tmk_core_protocol_lufa PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) -target_include_directories(tmk_core_protocol_lufa PUBLIC ${LUFA_PATH}) -target_link_libraries(tmk_core_protocol_lufa PUBLIC quantum) - -set(LUFA_ROOT_PATH ${CMAKE_SOURCE_DIR}/lib/lufa/LUFA) - -target_sources(tmk_core_protocol_lufa -PUBLIC - # ${LUFA_ROOT_PATH}/Drivers/USB/Core/${ARCH}/USBController_${ARCH}.c - # ${LUFA_ROOT_PATH}/Drivers/USB/Core/${ARCH}/USBInterrupt_${ARCH}.c - # ${LUFA_ROOT_PATH}/Drivers/USB/Core/ConfigDescriptors.c - # ${LUFA_ROOT_PATH}/Drivers/USB/Core/Events.c - # ${LUFA_ROOT_PATH}/Drivers/USB/Core/USBTask.c - # ${LUFA_ROOT_PATH}/Drivers/USB/Class/Common/HIDParser.c - - # ${LUFA_ROOT_PATH}/Drivers/USB/Core/${ARCH}/Host_${ARCH}.c - # ${LUFA_ROOT_PATH}/Drivers/USB/Core/${ARCH}/Pipe_${ARCH}.c - # ${LUFA_ROOT_PATH}/Drivers/USB/Core/${ARCH}/PipeStream_${ARCH}.c - # ${LUFA_ROOT_PATH}/Drivers/USB/Core/HostStandardReq.c - - # ${LUFA_ROOT_PATH}/Drivers/USB/Core/${ARCH}/Device_${ARCH}.c - # ${LUFA_ROOT_PATH}/Drivers/USB/Core/${ARCH}/Endpoint_${ARCH}.c - # ${LUFA_ROOT_PATH}/Drivers/USB/Core/${ARCH}/EndpointStream_${ARCH}.c - # ${LUFA_ROOT_PATH}/Drivers/USB/Core/DeviceStandardReq.c - - ${LUFA_ROOT_PATH}/Drivers/USB/Core/${ARCH}/USBController_${ARCH}.c - ${LUFA_ROOT_PATH}/Drivers/USB/Core/${ARCH}/USBInterrupt_${ARCH}.c - ${LUFA_ROOT_PATH}/Drivers/USB/Core/ConfigDescriptors.c - ${LUFA_ROOT_PATH}/Drivers/USB/Core/Events.c - ${LUFA_ROOT_PATH}/Drivers/USB/Core/USBTask.c - ${LUFA_ROOT_PATH}/Drivers/USB/Class/Common/HIDParser.c - - ${LUFA_ROOT_PATH}/Drivers/USB/Core/${ARCH}/Host_${ARCH}.c - ${LUFA_ROOT_PATH}/Drivers/USB/Core/${ARCH}/Pipe_${ARCH}.c - ${LUFA_ROOT_PATH}/Drivers/USB/Core/${ARCH}/PipeStream_${ARCH}.c - ${LUFA_ROOT_PATH}/Drivers/USB/Core/HostStandardReq.c - - ${LUFA_ROOT_PATH}/Drivers/USB/Core/${ARCH}/Device_${ARCH}.c - ${LUFA_ROOT_PATH}/Drivers/USB/Core/${ARCH}/Endpoint_${ARCH}.c - ${LUFA_ROOT_PATH}/Drivers/USB/Core/${ARCH}/EndpointStream_${ARCH}.c - ${LUFA_ROOT_PATH}/Drivers/USB/Core/DeviceStandardReq.c - -# ${LUFA_ROOT_PATH}/Drivers/USB/Class/Device/AudioClassDevice.c -# ${LUFA_ROOT_PATH}/Drivers/USB/Class/Device/CCIDClassDevice.c -# ${LUFA_ROOT_PATH}/Drivers/USB/Class/Device/CDCClassDevice.c -# ${LUFA_ROOT_PATH}/Drivers/USB/Class/Device/HIDClassDevice.c -# ${LUFA_ROOT_PATH}/Drivers/USB/Class/Device/MassStorageClassDevice.c -# ${LUFA_ROOT_PATH}/Drivers/USB/Class/Device/MIDIClassDevice.c -# ${LUFA_ROOT_PATH}/Drivers/USB/Class/Device/PrinterClassDevice.c -# ${LUFA_ROOT_PATH}/Drivers/USB/Class/Device/RNDISClassDevice.c - -# ${LUFA_ROOT_PATH}/Drivers/USB/Class/Host/AndroidAccessoryClassHost.c -# ${LUFA_ROOT_PATH}/Drivers/USB/Class/Host/AudioClassHost.c -# ${LUFA_ROOT_PATH}/Drivers/USB/Class/Host/CDCClassHost.c -# ${LUFA_ROOT_PATH}/Drivers/USB/Class/Host/HIDClassHost.c -# ${LUFA_ROOT_PATH}/Drivers/USB/Class/Host/MassStorageClassHost.c -# ${LUFA_ROOT_PATH}/Drivers/USB/Class/Host/MIDIClassHost.c -# ${LUFA_ROOT_PATH}/Drivers/USB/Class/Host/PrinterClassHost.c -# ${LUFA_ROOT_PATH}/Drivers/USB/Class/Host/RNDISClassHost.c -# ${LUFA_ROOT_PATH}/Drivers/USB/Class/Host/StillImageClassHost.c -) \ No newline at end of file +target_link_libraries(tmk_core_protocol_lufa PUBLIC lufa) +target_link_libraries(tmk_core_protocol_lufa PUBLIC quantum) \ No newline at end of file