Basic framework of cmake project

#The version of cmake used, required, according to the actual project

cmake_minimum_required(VERSION 3.0)

#Project name, custom
project (SDK) #Add
source files (.c/.cpp source files) in the specified directory
aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/src/ SRC_LIST_SDK ) #Set the list
of source files to be compiled
(APPEND SRC_LIST_ALL $ {SRC_LIST_SDK})

#Add header files that need to be compiled
include_directories(${CMAKE_CURRENT_LIST_DIR}/include/) #Set

compilation parameters
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${LOCAL_W_FLAGS} ${LOCAL_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LOCAL_W_FLAGS } ${LOCAL_C_FLAGS} -std=c++14 ") #Set

the linked library
link_directories(${CMAKE_CURRENT_LIST_DIR}/lib/) #Set
the linked library
link_libraries(z ssl crypto boost_system boost_program_options boost_filesystem boost_date_time boost_context boost_coroutine boost_chrono boost_log boost_thread boost_log_setup boost_regex boost_atomic pthread )

#Generate the target file as an executable file
add_executable(SDK ${SRC_LIST_ALL})

#Link to the final executable
target_link_libraries(SDK)


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325102764&siteId=291194637