Updated cmake example
This commit is contained in:
		
							parent
							
								
									18ccd55725
								
							
						
					
					
						commit
						2cd53c6ff1
					
				@ -29,28 +29,23 @@ if(TARGET spdlog)
 | 
				
			|||||||
    # then add an alias. This allows us to use the same "spdlog::spdlog"
 | 
					    # then add an alias. This allows us to use the same "spdlog::spdlog"
 | 
				
			||||||
    # below that a user would use (with the namespace)
 | 
					    # below that a user would use (with the namespace)
 | 
				
			||||||
    add_library(spdlog::spdlog ALIAS spdlog)
 | 
					    add_library(spdlog::spdlog ALIAS spdlog)
 | 
				
			||||||
    find_package(Threads REQUIRED)
 | 
					    add_library(spdlog::spdlog_header_only ALIAS spdlog_header_only)
 | 
				
			||||||
else()
 | 
					else()
 | 
				
			||||||
    # Stand-alone build
 | 
					    # Stand-alone build
 | 
				
			||||||
    find_package(spdlog REQUIRED)
 | 
					    find_package(spdlog REQUIRED)
 | 
				
			||||||
endif()
 | 
					endif()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#---------------------------------------------------------------------------------------
 | 
				
			||||||
# Example of using pre-compiled library
 | 
					# Example of using pre-compiled library
 | 
				
			||||||
 | 
					#---------------------------------------------------------------------------------------
 | 
				
			||||||
add_executable(example example.cpp)
 | 
					add_executable(example example.cpp)
 | 
				
			||||||
target_link_libraries(example spdlog::spdlog)
 | 
					target_link_libraries(example spdlog::spdlog)
 | 
				
			||||||
if(CMAKE_SYSTEM_NAME STREQUAL "Android")
 | 
					 | 
				
			||||||
    find_library(log-lib log)
 | 
					 | 
				
			||||||
    target_link_libraries(example log)
 | 
					 | 
				
			||||||
endif()
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#---------------------------------------------------------------------------------------
 | 
				
			||||||
# Example of using header-only library
 | 
					# Example of using header-only library
 | 
				
			||||||
 | 
					#---------------------------------------------------------------------------------------
 | 
				
			||||||
add_executable(example_header_only example.cpp)
 | 
					add_executable(example_header_only example.cpp)
 | 
				
			||||||
get_target_property(SPDLOG_INCLUDE_DIRS spdlog::spdlog INTERFACE_INCLUDE_DIRECTORIES)
 | 
					target_link_libraries(example_header_only spdlog::spdlog_header_only)
 | 
				
			||||||
target_include_directories(example_header_only PRIVATE ${SPDLOG_INCLUDE_DIRS})
 | 
					
 | 
				
			||||||
target_link_libraries(example_header_only Threads::Threads)
 | 
					 | 
				
			||||||
if(CMAKE_SYSTEM_NAME STREQUAL "Android")
 | 
					 | 
				
			||||||
    target_link_libraries(example_header_only log Threads::Threads)
 | 
					 | 
				
			||||||
endif ()
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/logs")
 | 
					file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/logs")
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user