mirror of
				https://github.com/TheLartians/ModernCppStarter.git
				synced 2025-10-31 02:01:33 +01:00 
			
		
		
		
	cleanup the sample
add only a build dependency (header only lib)
This commit is contained in:
		
							parent
							
								
									a4075a5534
								
							
						
					
					
						commit
						5f9aa807b9
					
				
					 5 changed files with 25 additions and 32 deletions
				
			
		|  | @ -1,4 +1,4 @@ | |||
| cmake_minimum_required(VERSION 3.14...3.19 FATAL_ERROR) | ||||
| cmake_minimum_required(VERSION 3.14...3.19) | ||||
| 
 | ||||
| # ---- Project ---- | ||||
| 
 | ||||
|  | @ -38,15 +38,11 @@ CPMAddPackage( | |||
|   VERSION 1.4 | ||||
| ) | ||||
| 
 | ||||
| find_package(fmt 6) | ||||
| if(NOT TARGET fmt::fmt-header-only) | ||||
|   # FIXME this add a target without namespace! CK | ||||
| CPMAddPackage( | ||||
|   NAME fmt | ||||
|   GIT_TAG 7.1.3 | ||||
|   GITHUB_REPOSITORY fmtlib/fmt | ||||
| ) | ||||
| endif() | ||||
| 
 | ||||
| # ---- Add source files ---- | ||||
| 
 | ||||
|  | @ -70,7 +66,7 @@ target_sources(Greeter PRIVATE ${headers} ${sources}) | |||
| # FIXME target_compile_options(Greeter PUBLIC "$<$<BOOL:${MSVC}>:/permissive->") | ||||
| 
 | ||||
| # Link dependencies (if required) | ||||
| target_link_libraries(Greeter PUBLIC fmt::fmt) | ||||
| target_link_libraries(Greeter PRIVATE fmt::fmt-header-only) | ||||
| 
 | ||||
| target_include_directories( | ||||
|   Greeter PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include> | ||||
|  | @ -92,5 +88,5 @@ packageProject( | |||
|   INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include | ||||
|   INCLUDE_DESTINATION include/${PROJECT_NAME}-${PROJECT_VERSION} | ||||
|   VERSION_HEADER "${VERSION_HEADER_LOCATION}" | ||||
|   DEPENDENCIES fmt | ||||
|   # XXX DEPENDENCIES fmt | ||||
| ) | ||||
|  |  | |||
|  | @ -1,7 +1,7 @@ | |||
| # this script adds all subprojects to a single build to allow IDEs understand the full project | ||||
| # structure. | ||||
| 
 | ||||
| cmake_minimum_required(VERSION 3.14...3.19 FATAL_ERROR) | ||||
| cmake_minimum_required(VERSION 3.14...3.19) | ||||
| 
 | ||||
| project(BuildAll LANGUAGES CXX) | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,4 +1,4 @@ | |||
| cmake_minimum_required(VERSION 3.14...3.19 FATAL_ERROR) | ||||
| cmake_minimum_required(VERSION 3.14...3.19) | ||||
| 
 | ||||
| project(GreeterDocs) | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,4 +1,4 @@ | |||
| cmake_minimum_required(VERSION 3.14 FATAL_ERROR) | ||||
| cmake_minimum_required(VERSION 3.14...3.19) | ||||
| 
 | ||||
| project(GreeterStandalone LANGUAGES CXX) | ||||
| 
 | ||||
|  | @ -21,10 +21,11 @@ CPMAddPackage(NAME Greeter SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/..) | |||
| 
 | ||||
| # ---- Create standalone executable ---- | ||||
| 
 | ||||
| file(GLOB sources CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/source/*.cpp) | ||||
| file(GLOB sources CONFIGURE_DEPENDS source/*.cpp) | ||||
| 
 | ||||
| add_executable(GreeterStandalone ${sources}) | ||||
| 
 | ||||
| set_target_properties(GreeterStandalone PROPERTIES CXX_STANDARD 17 OUTPUT_NAME "Greeter") | ||||
| # FIXME: WHY? CK | ||||
| # set_target_properties(GreeterStandalone PROPERTIES CXX_STANDARD 17 OUTPUT_NAME "Greeter") | ||||
| 
 | ||||
| target_link_libraries(GreeterStandalone Greeter::Greeter cxxopts) | ||||
|  |  | |||
|  | @ -1,4 +1,4 @@ | |||
| cmake_minimum_required(VERSION 3.14...3.19 FATAL_ERROR) | ||||
| cmake_minimum_required(VERSION 3.14...3.19) | ||||
| 
 | ||||
| project(GreeterTests LANGUAGES CXX) | ||||
| 
 | ||||
|  | @ -15,15 +15,11 @@ include(../cmake/tools.cmake) | |||
| 
 | ||||
| include(../cmake/CPM.cmake) | ||||
| 
 | ||||
| find_package(doctest) | ||||
| if(NOT TARGET doctest::doctest) | ||||
|   # FIXME this add a target without namespace! CK | ||||
| CPMAddPackage( | ||||
|   NAME doctest | ||||
|   GITHUB_REPOSITORY onqtam/doctest | ||||
|   GIT_TAG 2.3.7 | ||||
| ) | ||||
| endif() | ||||
| 
 | ||||
| if(TEST_INSTALLED_VERSION) | ||||
|   find_package(Greeter REQUIRED) | ||||
|  | @ -49,10 +45,10 @@ target_compile_features(GreeterTests PUBLIC cxx_std_17) | |||
| # enable compiler warnings | ||||
| if(NOT TEST_INSTALLED_VERSION) | ||||
|   if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU") | ||||
|     target_compile_options(Greeter PUBLIC -Wall -pedantic -Wextra -Werror) | ||||
|     target_compile_options(Greeter PRIVATE -Wall -pedantic -Wextra -Werror) | ||||
|   elseif(MSVC) | ||||
|     target_compile_options(Greeter PUBLIC /W4 /WX) | ||||
|     target_compile_definitions(GreeterTests PUBLIC DOCTEST_CONFIG_USE_STD_HEADERS) | ||||
|     target_compile_options(Greeter PRIVATE /W4 /WX) | ||||
|     target_compile_definitions(GreeterTests PRIVATE DOCTEST_CONFIG_USE_STD_HEADERS) | ||||
|   endif() | ||||
| endif() | ||||
| 
 | ||||
|  | @ -70,6 +66,6 @@ add_test(NAME GreeterTests COMMAND GreeterTests --success=false) | |||
| # ---- code coverage ---- | ||||
| 
 | ||||
| if(ENABLE_TEST_COVERAGE AND NOT TEST_INSTALLED_VERSION) | ||||
|   target_compile_options(Greeter PUBLIC -O0 -g -fprofile-arcs -ftest-coverage) | ||||
|   target_link_options(Greeter PUBLIC -fprofile-arcs -ftest-coverage) | ||||
|   target_compile_options(Greeter PRIVATE -O0 -g -fprofile-arcs -ftest-coverage) | ||||
|   target_link_options(Greeter PRIVATE -fprofile-arcs -ftest-coverage) | ||||
| endif() | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue