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

Improve CMakeLists.txt #2

Closed
wants to merge 3 commits into from
Closed
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
15 changes: 11 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,23 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

add_library(mylibrary STATIC)
add_library(mylib::mylibrary ALIAS mylibrary)

target_compile_features(mylibrary PUBLIC cxx_std_20)
target_sources(mylibrary
PRIVATE
PRIVATE
${CMAKE_SOURCE_DIR}/source/mylibrary.cpp
PUBLIC
PUBLIC
FILE_SET CXX_MODULES
BASE_DIRS source
FILES source/mylibrary.cppm
)

target_compile_options(${PROJECT_NAME} PUBLIC
$<$<COMPILE_LANG_AND_ID:CXX,Clang,GNU,ARMClang,AppleClang,LLC>:
$<BUILD_INTERFACE:-Werror;-Wall;-Wextra;-Wshadow;-Wunused;-pedantic>>
$<$<COMPILE_LANG_AND_ID:CXX,MSVC>:$<BUILD_INTERFACE:/W3>>
)

include(FetchContent)

FetchContent_Declare(
Expand Down Expand Up @@ -45,7 +52,7 @@ install(
EXPORT mylibrary-targets
FILE mylibrary-config.cmake
NAMESPACE mylib::
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/mylibrary
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/mylibrary
)

write_basic_package_version_file(
Expand All @@ -55,5 +62,5 @@ write_basic_package_version_file(

install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/mylibrary-config-version.cmake
DESTINATION ${CMAKE_INSTALL_DATADIR}/mylibrary
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/mylibrary
)
Loading