cmake_minimum_required(VERSION2.8)macro(mac_printmsg)set(mac"macro")message("${mac}: ${msg}")endmacro(mac_print)function(func_printmsg)set(func"func")message("${func}: ${msg}")endfunction(func_print)mac_print("test macro")message("check var in macro: ${mac}")func_print("test function")message("check var in function: ${func}")
cmake_minimum_required(VERSION2.8)# Project dataproject(testcmake)# Directoriesset(SRC_DIRsrc)set(LIB_DIRlibs)set(INC_DIRinclude)# Release modeset(CMAKE_BUILD_TYPEDebug)# Compile flagsset(CMAKE_C_FLAGS"-Wall -Werror")# I like verbose, must after project, do not know whyset(CMAKE_VERBOSE_MAKEFILEtrue)# Where to include?include_directories(${INC_DIR})# Files to compileset(test_SRCS${SRC_DIR}/test.c${LIB_DIR}/liba.c${LIB_DIR}/libb.c)add_executable(${PROJECT_NAME}${test_SRCS})
cmake_minimum_required(VERSION2.8)# Project dataproject(testcmake)# Directoriesset(SRC_DIRsrc)set(LIB_DIRlibs)set(INC_DIRinclude)# Release modeset(CMAKE_BUILD_TYPEDebug)# Compile flagsset(CMAKE_C_FLAGS"-Wall -Werror")# I like verbose, must after project, do not know whyset(CMAKE_VERBOSE_MAKEFILEtrue)# Where to include?include_directories(${INC_DIR})# Build librariesset(liba_SRCS${LIB_DIR}/liba.c)set(libb_SRCS${LIB_DIR}/libb.c)add_library(aSHARED${liba_SRCS})add_library(bSHARED${libb_SRCS})# Build binaryset(test_SRCS${SRC_DIR}/test.c)add_executable(${PROJECT_NAME}${test_SRCS})target_link_libraries(${PROJECT_NAME}ab)
cmake_minimum_required(VERSION2.8)# Project dataproject(testcmake)# Directoriesset(SRC_DIRsrc)set(LIB_DIRlibs)set(INC_DIRinclude)# Release modeset(CMAKE_BUILD_TYPEDebug)# Compile flagsset(CMAKE_C_FLAGS"-Wall -Werror")# I like verbose, must after project, do not know whyset(CMAKE_VERBOSE_MAKEFILEtrue)# Where to include?include_directories(${INC_DIR})# Build library in libs directory or not?# Dive into libs directoryadd_subdirectory(${SRC_DIR})add_subdirectory(${LIB_DIR})
libs/CMakeLists.txt
libs/CMakeLists.txt
123456
# Build binary, inherit setting from parentset(liba_SRCSliba.c)set(libb_SRCSlibb.c)add_library(a${liba_SRCS})add_library(b${libb_SRCS})