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