1cmake_minimum_required(VERSION 3.0.0 FATAL_ERROR)
2
3# Set up the project
4project(guix
5    LANGUAGES C ASM
6)
7
8if(NOT DEFINED THREADX_ARCH)
9    message(FATAL_ERROR "Error: THREADX_ARCH not defined")
10endif()
11if(NOT DEFINED THREADX_TOOLCHAIN)
12    message(FATAL_ERROR "Error: THREADX_TOOLCHAIN not defined")
13endif()
14
15# Define our target library and an alias for consumers
16add_library(${PROJECT_NAME})
17add_library("azrtos::${PROJECT_NAME}" ALIAS ${PROJECT_NAME})
18
19# Define any required dependencies between this library and others
20target_link_libraries(${PROJECT_NAME} PUBLIC
21    "azrtos::threadx"
22)
23
24# A place for generated/copied include files (no need to change)
25set(CUSTOM_INC_DIR ${CMAKE_CURRENT_BINARY_DIR}/custom_inc)
26
27# Pick up the port specific stuff first
28if(DEFINED GUIX_CUSTOM_PORT)
29    add_subdirectory(${GUIX_CUSTOM_PORT} guix_port)
30else()
31    add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/ports/${THREADX_ARCH}/${THREADX_TOOLCHAIN})
32endif()
33
34# Then the common files
35add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/common)
36
37
38
39
40# Include the user's override file if required
41if (NOT GX_USER_FILE)
42    message(STATUS "Using default gx_user.h file")
43    set(GX_USER_FILE ${CMAKE_CURRENT_LIST_DIR}/common/inc/gx_user_sample.h)
44else()
45    message(STATUS "Using custom gx_user.h file from ${GX_USER_FILE}")
46endif()
47configure_file(${GX_USER_FILE} ${CUSTOM_INC_DIR}/gx_user.h COPYONLY)
48target_include_directories(${PROJECT_NAME}
49    PUBLIC
50    ${CUSTOM_INC_DIR}
51)
52target_compile_definitions(${PROJECT_NAME} PUBLIC "GX_INCLUDE_USER_DEFINE_FILE" )
53
54# Enable a build target that produces a ZIP file of all sources
55set(CPACK_SOURCE_GENERATOR "ZIP")
56set(CPACK_SOURCE_IGNORE_FILES
57  \\.git/
58  \\.github/
59  _build/
60  \\.git
61  \\.gitattributes
62  \\.gitignore
63  ".*~$"
64)
65set(CPACK_VERBATIM_VARIABLES YES)
66include(CPack)