Skip to content

Commit

Permalink
fix: 🐛 link commands to saber library to inherit utility methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Xminent committed Dec 10, 2023
1 parent c6755d7 commit 6b63c3b
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,34 +46,34 @@ cpmfindpackage(
)

file(GLOB_RECURSE sources CONFIGURE_DEPENDS "include/*.hpp" "src/*.cpp")
list(FILTER sources EXCLUDE REGEX ".*main\\.cpp$")

add_executable(${PROJECT_NAME} ${sources})
add_library(${PROJECT_NAME}_lib ${sources})
add_executable(${PROJECT_NAME} src/main.cpp)

target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_17)
target_compile_features(${PROJECT_NAME}_lib PUBLIC cxx_std_17)

if(WIN32)
target_compile_definitions(${PROJECT_NAME} PRIVATE _CRT_SECURE_NO_WARNINGS)
endif()

target_include_directories(
${PROJECT_NAME} PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
${PROJECT_NAME}_lib PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)

target_link_libraries(${PROJECT_NAME} PRIVATE ekizu spdlog::spdlog)
target_link_libraries(${PROJECT_NAME}_lib PUBLIC ekizu spdlog::spdlog)
target_link_libraries(${PROJECT_NAME} PRIVATE ${PROJECT_NAME}_lib)

file(GLOB_RECURSE commands CONFIGURE_DEPENDS commands/*.cpp)

foreach(fullcmdname ${commands})
get_filename_component(cmdname ${fullcmdname} NAME_WE)
message(STATUS "Found command:'cmd_${cmdname}'")
add_library(cmd_${cmdname} SHARED ${fullcmdname})
target_include_directories(
cmd_${cmdname} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
)
target_link_libraries(cmd_${cmdname} PRIVATE ekizu spdlog::spdlog)
target_link_libraries(cmd_${cmdname} PRIVATE ${PROJECT_NAME}_lib)
endforeach(fullcmdname)

if(${PROJECT_NAME}_INSTALL)
install(TARGETS ${PROJECT_NAME} DESTINATION bin)
endif()
endif()

0 comments on commit 6b63c3b

Please sign in to comment.