-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
79 lines (66 loc) · 3.14 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#设置最低的编译版本
cmake_minimum_required(VERSION 3.10)
#项目名称
project(pros_lvgl_sim)
#设置c/c++标准
set(CMAKE_C_STANDARD 11)#C11
set(CMAKE_CXX_STANDARD 17)#C17
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set (AS_A_SUBPROJECT 1)#设置成1 迫使后续模块使用静态库形式导入
set (MAKE_LVGL_DRIVE_STATIC_LIB OFF)# OFF正常编译 ON生成静态库
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/build) #设置二进制文件存放路径
#头文件路径
include_directories(
${TOOLCHAIN_INC_DIR}
"./include"
"./ncrapi_lvgl_sim_kernel"
"./ncrapi_lvgl_sim_kernel/freeRTOS/src/Configuration Files"
"./ncrapi_lvgl_sim_kernel/freeRTOS/src/External dependence"
"./ncrapi_lvgl_sim_kernel/freeRTOS/src/FreeRTOS/include"
"./ncrapi_lvgl_sim_kernel/freeRTOS/src/useInit"
)
#关闭警告
add_compile_options(-Wno-unused-private-field -Wno-unused-variable -Wno-deprecated-declarations -Wno-unused-function -Wno-implicit-function-declaration)
#添加需要链接的库文件目录 新建好了 链接的时候用
LINK_DIRECTORIES(
"./ncrapi_lvgl_sim_kernel/lib"
"C:/Program Files (x86)/Windows Kits/10/Lib/10.0.18362.0/um/x64"
"C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.24.28314/lib/x64"
"C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.24.28314/atlmfc/lib/x64"
"C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Auxiliary/VS/lib/x64"
"C:/Program Files (x86)/Windows Kits/10/lib/10.0.18362.0/ucrt/x64"
"C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Auxiliary/VS/UnitTest/lib"
"C:/Program Files (x86)/Windows Kits/NETFXSDK/4.7.2/lib/um/x64")
#######################加入freeRTOS模块#########################
add_subdirectory ("./ncrapi_lvgl_sim_kernel/freeRTOS")
set (EXTRA_LIBS ${EXTRA_LIBS} freeRTOS)
############################################################################
#######################加入ncrapi_lvgl_sim_kernel模块#########################
add_subdirectory ("./ncrapi_lvgl_sim_kernel")
set (EXTRA_LIBS ${EXTRA_LIBS} ncrapi_lvgl_sim_kernel)
############################################################################
if(NOT MAKE_LVGL_DRIVE_STATIC_LIB)
#枚举本地源文件
file(GLOB_RECURSE SOURCES
"src/*.c"
"src/*.cpp" )
#生成可执行文件
add_executable(main ${SOURCES})
if(CMAKE_HOST_SYSTEM_NAME STREQUAL Linux)
message(STATUS "linux")
#寻找sdl2
find_package(SDL2 REQUIRED SDL2)
include_directories(${SDL2_INCLUDE_DIRS})
target_link_libraries(main PRIVATE SDL2 lvgl_gcc drivers_gcc pthread ${EXTRA_LIBS})#不链接pthread easylog编译报错
elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL Windows)
message(STATUS "windows")
#添加-D
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
target_link_libraries(main PRIVATE SDL2 SDL2main drivers_clang_win lvgl_clang_win ${EXTRA_LIBS})#不链接pthread easylog编译报错
else()
message(STATUS "无法判断属于哪种系统!")
endif()
#添加一个run命令
add_custom_target (run COMMAND ninja all COMMAND ${EXECUTABLE_OUTPUT_PATH}/main)
else()
endif()