Use ${PROJECT_NAME} instead of writing projectname multiple times (#134)

* Remove duplicate mentions of project name and replaced it with ${PROJECT_NAME} variable

Update CMakeLists.txt

* Added ${CMAKE_PROJECT_NAME}

* reverted usage of  to Greeter and ran fix-format

* Update test/CMakeLists.txt

Co-authored-by: Dominic Dinser <dominic.dinser@leica-geosystems.com>
Co-authored-by: Lars Melchior <TheLartians@users.noreply.github.com>
This commit is contained in:
Dominic 2021-10-17 21:10:52 +02:00 committed by GitHub
parent 69320a663b
commit e0bf3f59d1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 16 deletions

View file

@ -43,20 +43,20 @@ file(GLOB_RECURSE sources CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/source/
# ---- Create library ----
# Note: for header-only libraries change all PUBLIC flags to INTERFACE and create an interface
# target: add_library(Greeter INTERFACE)
add_library(Greeter ${headers} ${sources})
# target: add_library(${PROJECT_NAME} INTERFACE)
add_library(${PROJECT_NAME} ${headers} ${sources})
set_target_properties(Greeter PROPERTIES CXX_STANDARD 17)
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 17)
# being a cross-platform target, we enforce standards conformance on MSVC
target_compile_options(Greeter PUBLIC "$<$<COMPILE_LANG_AND_ID:CXX,MSVC>:/permissive->")
target_compile_options(${PROJECT_NAME} PUBLIC "$<$<COMPILE_LANG_AND_ID:CXX,MSVC>:/permissive->")
# Link dependencies
target_link_libraries(Greeter PRIVATE fmt::fmt)
target_link_libraries(${PROJECT_NAME} PRIVATE fmt::fmt)
target_include_directories(
Greeter PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include/${PROJECT_NAME}-${PROJECT_VERSION}>
${PROJECT_NAME} PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include/${PROJECT_NAME}-${PROJECT_VERSION}>
)
# ---- Create an installable target ----