Skip to content

Commit

Permalink
Add system name to target
Browse files Browse the repository at this point in the history
Signed-off-by: Darshan Sen <raisinten@gmail.com>
  • Loading branch information
RaisinTen committed Apr 5, 2024
1 parent 41da37f commit 79e38b9
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 16 deletions.
7 changes: 5 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ option(BENONI_TESTS "Build the Benoni tests" OFF)
option(BENONI_EXAMPLES "Build the Benoni examples" OFF)
option(BENONI_INSTALL "Install Benoni" ON)

string(TOLOWER ${CMAKE_SYSTEM_NAME} LOWER_SYSTEM_NAME)
set(BENONI_TARGET ${PROJECT_NAME}_${LOWER_SYSTEM_NAME})

if(APPLE)
add_subdirectory(src/apple)
elseif(WIN32)
Expand All @@ -18,12 +21,12 @@ elseif(UNIX)
add_subdirectory(src/linux)
endif()

set_target_properties(benoni PROPERTIES PUBLIC_HEADER ${PROJECT_SOURCE_DIR}/include/benoni/http.h)
set_target_properties(${BENONI_TARGET} PROPERTIES PUBLIC_HEADER ${PROJECT_SOURCE_DIR}/include/benoni/http.h)

if(BENONI_INSTALL)
include(GNUInstallDirs)

install(TARGETS benoni
install(TARGETS ${BENONI_TARGET}
EXPORT benoni
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}"
COMPONENT benoni
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ example: .always
$(EXAMPLE)

test: .always
$(CTEST) -C Debug --test-dir build --parallel
$(CTEST) -C Debug --test-dir build --parallel --output-on-failure

# For NMake, which doesn't support .PHONY
.always:
2 changes: 1 addition & 1 deletion examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
add_executable(http_example http_example.cc)

target_link_libraries(http_example PRIVATE benoni)
target_link_libraries(http_example PRIVATE ${BENONI_TARGET})
8 changes: 4 additions & 4 deletions src/apple/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
add_library(benoni STATIC http.mm)
add_library(${BENONI_TARGET} STATIC http.mm)

target_compile_options(benoni PUBLIC "-fobjc-arc")
target_compile_options(${BENONI_TARGET} PUBLIC "-fobjc-arc")

target_include_directories(benoni PUBLIC
target_include_directories(${BENONI_TARGET} PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/include>)

target_link_libraries(benoni PUBLIC "-framework Foundation")
target_link_libraries(${BENONI_TARGET} PUBLIC "-framework Foundation")
6 changes: 3 additions & 3 deletions src/linux/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
add_library(benoni STATIC http.cc)
add_library(${BENONI_TARGET} STATIC http.cc)

target_include_directories(benoni PUBLIC
target_include_directories(${BENONI_TARGET} PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/include>)

target_link_libraries(benoni PUBLIC libsoup)
target_link_libraries(${BENONI_TARGET} PUBLIC libsoup)
6 changes: 3 additions & 3 deletions src/win32/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
add_library(benoni STATIC http.cc)
add_library(${BENONI_TARGET} STATIC http.cc)

target_include_directories(benoni PUBLIC
target_include_directories(${BENONI_TARGET} PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/include>)

target_link_libraries(benoni PUBLIC "Winhttp.lib")
target_link_libraries(${BENONI_TARGET} PUBLIC "Winhttp.lib")
6 changes: 5 additions & 1 deletion test/packaging/project/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@ add_subdirectory(
"${CMAKE_CURRENT_BINARY_DIR}/benoni_build")

add_executable(project project.cc)
target_link_libraries(project PRIVATE benoni)

string(TOLOWER ${CMAKE_SYSTEM_NAME} LOWER_SYSTEM_NAME)
set(BENONI_TARGET benoni_${LOWER_SYSTEM_NAME})

target_link_libraries(project PRIVATE ${BENONI_TARGET})
2 changes: 1 addition & 1 deletion test/unit/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
add_executable(postman_echo_get postman-echo-get.cc)

target_link_libraries(postman_echo_get PRIVATE benoni)
target_link_libraries(postman_echo_get PRIVATE ${BENONI_TARGET})

add_test(NAME postman_echo_get COMMAND $<TARGET_FILE:postman_echo_get>)

0 comments on commit 79e38b9

Please sign in to comment.