cmake_minimum_required(VERSION 3.5) include(cmakeProjectConfig.cmake) set(BSL_DIR ${CMAKE_SOURCE_DIR}/bsl/${BSL_USED}) if(EXISTS ${BSL_DIR}) # Cheking if the directory exists message("${BoldGreen}Compiling for ${BSL_USED} ${ColourReset}") set(COMPILER_DEFS ${BSL_DIR}/bslCompiler.cmake) set(PROJECT_DEFS ${BSL_DIR}/bslConfig.cmake) elseif(BSL_USED STREQUAL "raspberry") message("${BoldGreen}Compiling for ${BSL_USED} ${ColourReset}") else() message( FATAL_ERROR "${BoldRed}Please Select a valid BSL, CMake will exit.${ColourReset}" ) endif() include(${COMPILER_DEFS}) project(${BSL_USED} ASM C CXX) #do this intead sf declaring languages in the beginning it will prevent loop errors. set(CMAKE_VERBOSE_MAKEFILE off) #Shoul make print everythign ?? set(EXECUTABLE ${PROJECT_NAME}) #Create the executable #################################################################################################### #CONFIG FILE #################################################################################################### set(INTERFACES_DIR ${CMAKE_SOURCE_DIR}/bsl/csl/interfaces) #################################################################################################### #SUBDIRECTORIES #################################################################################################### include(${PROJECT_DEFS}) add_subdirectory(bsl) #The order is important list(APPEND EXTRA_LIBS sub::startup) list(APPEND EXTRA_LIBS sub::translator) list(APPEND EXTRA_LIBS sub::sources) list(APPEND EXTRA_LIBS sub::gpio) message("${BoldBlue}Project Info ${ColourReset}") message("${Blue} |--> Exec Name \t: ${EXECUTABLE} ${ColourReset}") message("${Blue} |--> Compiler Def\t: ${COMPILER_DEFS} ${ColourReset}") message("${Blue} |--> Project Def\t: ${PROJECT_DEFS} ${ColourReset}") message("${Blue} |--> Interfaces Dir\t: ${INTERFACES_DIR} ${ColourReset}") message("${Blue} |--> Libs used\t\t: ${EXTRA_LIBS} ${ColourReset}") #################################################################################################### #EXECUTABLE #################################################################################################### add_executable(${EXECUTABLE} main.cpp) target_compile_options(${EXECUTABLE} PRIVATE ${CPP_FLAGS}) target_compile_definitions(${EXECUTABLE} PRIVATE ${CPP_DEFS}) target_include_directories(${EXECUTABLE} PUBLIC ${CPP_INCLUDES}) #################################################################################################### #LINKING EXECUTEABLE #################################################################################################### if(IS_NO_SYS) message("${Cyan}Using specifier Linker script ${ColourReset}") message("${Cyan} |--> ${LINKER} ${ColourReset}") target_link_libraries(${EXECUTABLE} ${EXTRA_LIBS}) target_link_options(${EXECUTABLE} PRIVATE ${LINKER_FLAGS}) endif() #################################################################################################### #CUSTOM COMMANDS #################################################################################################### if(NEED_OBJCOPY) add_custom_command(TARGET ${EXECUTABLE} POST_BUILD COMMAND ${CMAKE_OBJCOPY} -O ihex ${EXECUTABLE} ${PROJECT_NAME}.hex COMMAND ${CMAKE_OBJCOPY} -O binary ${EXECUTABLE} ${PROJECT_NAME}.bin) endif() add_custom_command(TARGET ${EXECUTABLE} POST_BUILD COMMAND ${CMAKE_SIZE} ${EXECUTABLE}) #################################################################################################### #CUSTOM Comments from dev. #################################################################################################### # Link For header dependency : https://stackoverflow.com/questions/11216408/cmake-dependencies-headers-between-apps-libraries-in-same-project # This is one possible trick to handle the assenbly compiling. # We can't use arm-non-eabi-as because it can onaly hande macros. # So this bizzare Variable makes shure that whne the asembly compiling is called the -x assembler-with-cpp flag is passed # target_compile_options(${EXECUTABLE} PRIVATE # $<$:-x assembler-with-cpp ${ASM_FLAGS}>)