Fix cmake build with PK_DLL
Some checks failed
CI / style-check (push) Successful in 14s
CI / linux-build (push) Successful in 15s
CI / windows-build (push) Has been cancelled
CI / macos-build (push) Has been cancelled

This commit is contained in:
Zeke Xiao 2024-12-17 07:15:56 +00:00
parent 8c8b87a8f4
commit 83c1693489

View File

@ -5,27 +5,29 @@ cmake_minimum_required(VERSION 3.5)
project(pocket C)
set(POCKET_SRC_DIRS
${CMAKE_CURRENT_SOURCE_DIR}/src/core
${CMAKE_CURRENT_SOURCE_DIR}/src/libs
${CMAKE_CURRENT_SOURCE_DIR}/src/core
${CMAKE_CURRENT_SOURCE_DIR}/src/libs
)
add_compile_definitions(PK_DLL)
file(GLOB POCKET_SOURCES "")
foreach(POCKET_SRC_DIR ${POCKET_SRC_DIRS})
foreach (POCKET_SRC_DIR ${POCKET_SRC_DIRS})
file(GLOB SOURCES "${POCKET_SRC_DIR}/*.c")
list(APPEND POCKET_SOURCES ${SOURCES})
endforeach()
endforeach ()
add_library(${PROJECT_NAME} ${POCKET_SOURCES})
target_include_directories(${PROJECT_NAME} PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/src/include)
if(NOT MSVC)
${CMAKE_CURRENT_SOURCE_DIR}/src/include)
target_compile_definitions(${PROJECT_NAME} PRIVATE PK_COMPILE)
if (NOT MSVC)
target_link_libraries(${PROJECT_NAME} m dl)
target_compile_options(${PROJECT_NAME} PRIVATE -fPIC)
endif()
endif ()
# if pocket is top level proejct build cli
if(${PROJECT_NAME} STREQUAL ${CMAKE_PROJECT_NAME})
if (${PROJECT_NAME} STREQUAL ${CMAKE_PROJECT_NAME})
add_executable(${PROJECT_NAME}cli ${CMAKE_SOURCE_DIR}/cli/main.c)
target_link_libraries(${PROJECT_NAME}cli ${PROJECT_NAME})
endif()
endif ()