build demo-01 is ok

This commit is contained in:
lyon tab s7 2021-08-21 16:47:50 +08:00
parent e0f9de3d97
commit 493502a0dc
2 changed files with 11 additions and 44 deletions

View File

@ -1,7 +1,9 @@
cmake_minimum_required(VERSION 3.0.0)
project(msc VERSION 0.1.0)
project(pikascript VERSION 0.1.0)
include_directories(src/package/pikascript-core)
include_directories(src/boot/demo01-led)
add_subdirectory(src/package/pikascript-core)
add_subdirectory(src/boot/demo01-led)

View File

@ -1,43 +1,8 @@
#
string(REGEX REPLACE "/$" "" CURRENT_FOLDER_ABSOLUTE ${CMAKE_CURRENT_SOURCE_DIR})
string(REGEX REPLACE ".*/(.*)" "\\1" CURRENT_FOLDER ${CURRENT_FOLDER_ABSOLUTE})
# main.c
file(GLOB_RECURSE main_file ./*main.c*)
# .a
file(GLOB_RECURSE lib_file ${PROJECT_SOURCE_DIR}/lib/*.a)
#
include_directories(${PROJECT_SOURCE_DIR}/include)
# 添加第三方库(add)
link_directories(${PROJECT_SOURCE_DIR}/lib)
#
ADD_EXECUTABLE(${CURRENT_FOLDER}.bin ${main_file})
# ---------------------------------------> START support clang
llvm_map_components_to_libnames(llvm_libs support core irreader)
# Link against LLVM libraries
target_link_libraries(${CURRENT_FOLDER}.bin ${llvm_libs})
# ---------------------------------------> START support clang
TARGET_LINK_LIBRARIES(${CURRENT_FOLDER}.bin
-Wl,--start-group
${lib_file}
-Wl,--end-group
)
#
#execute_process(
#COMMAND ls ${PROJECT_SOURCE_DIR}/lib
#OUTPUT_VARIABLE libs
# )
#string(REPLACE "\n" ";" libList ${libs})
#foreach(item ${libList})
#message("add lib: ${item}")
#TARGET_LINK_LIBRARIES(${CURRENT_FOLDER}_exe ${PROJECT_SOURCE_DIR}/lib/${item})
#endforeach()
set(BINARY ${CMAKE_PROJECT_NAME}_demo01-led)
file(GLOB_RECURSE THIS_SOURCES LIST_DIRECTORIES false *.h *.cpp *.c)
set(SOURCES ${THIS_SOURCES})
add_executable(${BINARY} ${THIS_SOURCES})
# srclibgtest
target_link_libraries(${BINARY} PUBLIC
${CMAKE_PROJECT_NAME}-core
)