Skip to content

Commit

Permalink
fix(cmake): properly expose public headers
Browse files Browse the repository at this point in the history
  • Loading branch information
Yimura committed Jan 18, 2023
1 parent e228a6a commit cac2581
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ endif()
file(GLOB_RECURSE SRC_FILES
"${SRC_DIR}/**.cpp"
"${SRC_DIR}/**.hpp"
)
file(GLOB_RECURSE PUBLIC_HEADER_FILES
"${PUBLIC_HEADER_DIR}/**.hpp"
)

add_library(${PROJECT_NAME} STATIC ${SRC_FILES})
add_library(${PROJECT_NAME} STATIC ${SRC_FILES} ${PUBLIC_HEADER_FILES})

if(CXX_FORMAT_SUPPORT)
message("Using std::format for formatting, you can set USE_FMT to force fmt::format instead.")
Expand All @@ -42,8 +44,12 @@ endif()
find_package(Threads REQUIRED)
target_link_libraries(${PROJECT_NAME} Threads::Threads )

set_target_properties(${PROJECT_NAME} PROPERTIES PUBLIC_HEADER "${PUBLIC_HEADER_DIR}")
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 20)

target_precompile_headers(${PROJECT_NAME} PUBLIC "${SRC_DIR}/common.hpp")
target_include_directories(${PROJECT_NAME} PUBLIC ${SRC_DIR} "${PUBLIC_HEADER_DIR}/AsyncLogger/")
target_include_directories(${PROJECT_NAME} PRIVATE "${PUBLIC_HEADER_DIR}/AsyncLogger/")
target_include_directories(${PROJECT_NAME} PUBLIC "${SRC_DIR}")
target_precompile_headers(${PROJECT_NAME} PRIVATE "${SRC_DIR}/common.hpp")

# public stuff
set_target_properties(${PROJECT_NAME} PROPERTIES PUBLIC_HEADER "${PUBLIC_HEADER_FILES}")
target_include_directories(${PROJECT_NAME} PUBLIC "${PUBLIC_HEADER_DIR}")

0 comments on commit cac2581

Please sign in to comment.