Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: export targets and cmake files, add BUILD_TESTING check #18

Merged
merged 4 commits into from
Jul 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ jobs:
uses: egor-tensin/setup-gcc@v1
with:
version: 11
- name: install libfmt-dev
run: sudo apt-get install -y libfmt-dev

- uses: actions/checkout@master
with:
Expand All @@ -17,7 +19,7 @@ jobs:
- name: build
run: |
mkdir build-debug
cmake -H. -Bbuild-debug -DCMAKE_BUILD_TYPE=Debug
cmake -H. -Bbuild-debug -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=ON
cmake --build build-debug -j
- name: test
run: ./build-debug/test/ut/asyncio_ut
49 changes: 25 additions & 24 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@ project(${TARGET_NAME}

set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address")
set (CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address")
message(CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE})

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

###############################################################################
set(ASYNCIO_INC
include/asyncio/asyncio_ns.h
include/asyncio/task.h
Expand Down Expand Up @@ -42,21 +40,19 @@ set(ASYNCIO_INC
include/asyncio/finally.h
)

include_directories(${CMAKE_SOURCE_DIR}/include)
add_library(asyncio SHARED
${ASYNC_INC}
src/event_loop.cpp)
target_link_libraries(asyncio PUBLIC fmt::fmt)

add_subdirectory(test)
add_subdirectory(third_party)
if (BUILD_TESTING)
add_subdirectory(third_party/Catch2)
add_subdirectory(third_party/nanobench)
add_subdirectory(test)
endif()

set(MODELS_CMAKE_FILES
"cmake/asyncioConfig.cmake"
"cmake/asyncioConfigVersion.cmake"
)
include(GNUInstallDirs)

add_compile_options(-fPIC)
find_package(fmt REQUIRED)

set_target_properties(${PROJECT_NAME}
PROPERTIES
Expand All @@ -66,20 +62,25 @@ PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}"
)

set(MODELS_LIBRARY_INSTALL_DIR "/usr/lib/")
set(MODELS_CMAKE_FILES_INSTALL_DIR "/usr/lib/cmake/asyncio/")
set(MODELS_HEADER_INSTALL_DIR "/usr/")
target_compile_options(${PROJECT_NAME} PUBLIC -fPIC)

# INSTALL CONFIGURATIONS
include(GNUInstallDirs)
target_include_directories(${PROJECT_NAME} PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)

foreach ( file ${ASYNCIO_INC} )
get_filename_component( dir ${file} DIRECTORY )
install( FILES ${file} DESTINATION "${MODELS_HEADER_INSTALL_DIR}${dir}")
endforeach()
target_link_libraries(asyncio PUBLIC fmt::fmt)

install(
DIRECTORY ${CMAKE_SOURCE_DIR}/include/asyncio
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)

install(TARGETS ${TARGET_NAME}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(TARGETS ${TARGET_NAME} EXPORT ${TARGET_NAME}Targets
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin)

install(FILES ${MODELS_CMAKE_FILES}
DESTINATION ${MODELS_CMAKE_FILES_INSTALL_DIR})
install(EXPORT ${TARGET_NAME}Targets
FILE ${TARGET_NAME}Config.cmake
NAMESPACE ${TARGET_NAME}::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/asyncio)
5 changes: 0 additions & 5 deletions cmake/asyncioConfig.cmake

This file was deleted.

11 changes: 0 additions & 11 deletions cmake/asyncioConfigVersion.cmake

This file was deleted.

3 changes: 0 additions & 3 deletions third_party/CMakeLists.txt

This file was deleted.