命令查询列表:http://www.cmake.org/cmake/help/v3.2/manual/cmake-commands.7.html
#
# Official dependency number 0: CMake.
# Obviously, we must have it if we are here but test version.
#
CMAKE_MINIMUM_REQUIRED( VERSION 2.6 FATAL_ERROR )
#
# Enter some information about the project
# This is the only configurable part of the build system
#
# project name
PROJECT( stamp )
SET (CMAKE_VERBOSE_MAKEFILE "1")
#设置编译器
SET (CMAKE_CXX_COMPILER "g++")
# 使用-Wno-deprecated-declarations -Wno-deprecated,
去掉对于gcc4.6的一些报警
SET (CMAKE_CXX_FLAGS "-std=c++0x -fPIC -Wall -O2 -DNEWARCH -DPOSIX -DPOSIX-DMONGO_HAVE_STDINT -D__STDC_LIMIT_MACROS -Wno-deprecated-declarations-Wno-deprecated")
SET (CMAKE_C_FLAGS "-fPIC -Wall -O2 -DNEWARCH -DPOSIX -DMONGO_HAVE_STDINT-fno-strict-aliasing -fwrapv -Wstrict-prototypes")
#SET (CMAKE_SHARED_LINKER_FLAGS "-L/opt/lib/python2.7/config -lpthread-ldl -lutil -lm -lpython2.7 -Xlinker -export-dynamic")
#设置路径
MESSAGE ( STATUS "**************** Release ****************" )
SET (PROJECT_ROOT_DIR "../" )
#
# The out-of-source building directory
#
#INCLUDE( "../conf/${PROJECT_NAME}.cmake" )
GET_FILENAME_COMPONENT( PROJECT_BUILD_DIR"${${PROJECT_NAME}_SOURCE_DIR}" ABSOLUTE ) #把中间路径的值赋予第一个参数
GET_FILENAME_COMPONENT( PROJECT_ROOT_DIR "${PROJECT_BUILD_DIR}/../"ABSOLUTE )
GET_FILENAME_COMPONENT( PROJECT_CMAKE_DIR"${PROJECT_BUILD_DIR}/cmake/" ABSOLUTE )
MESSAGE( STATUS "DEBUG: ${PROJECT_NAME}_SOURCE_DIR${${PROJECT_NAME}_SOURCE_DIR}" )
MESSAGE( STATUS "DEBUG: PROJECT_ROOT_DIR ${PROJECT_ROOT_DIR}" )
MESSAGE( STATUS "DEBUG: PROJECT_CMAKE_DIR ${PROJECT_CMAKE_DIR}")
#包含其他cmake
# optional cmake prepare modules
INCLUDE( "cmake/contrib.cmake" OPTIONAL )
INCLUDE( "cmake/UseBoost.cmake" OPTIONAL )
INCLUDE( "cmake/UseIce.cmake" OPTIONAL )
INCLUDE( "cmake/slice.cmake" OPTIONAL )
INCLUDE( "cmake/UsePython.cmake" OPTIONAL )
# -----------------------------------------------------------------------------------
INCLUDE_DIRECTORIES( "${PROJECT_ROOT_DIR}/src/cpp/include" )
INCLUDE_DIRECTORIES( "/opt/Python-2.7/include" )
INCLUDE_DIRECTORIES( "/opt/Python-2.7/include/python2.7" )
#INCLUDE_DIRECTORIES( "../../../../../common/BfdProto/trunk/release/tmp/proto/")
#Generate a list of files that match the <globbing-expressions> and
store it into the <variable>生成文件列表
FILE( GLOB BUILD_SRC_RECOMMEND_SOURCE"${PROJECT_ROOT_DIR}/src/cpp/common/*.cpp""${PROJECT_ROOT_DIR}/src/cpp/common/*.cc" )
FILE( GLOB BUILD_SRC_RABBIT_SOURCE"${PROJECT_ROOT_DIR}/src/cpp/stamp/*.cpp" )
FILE( GLOB BUILD_SRC_RULE_SOURCE "${PROJECT_ROOT_DIR}/src/cpp/rule_engine/*.cpp")
FILE( GLOB BUILD_SRC_OPERATOR_SOURCE"${PROJECT_ROOT_DIR}/src/cpp/modules/operator/*.cpp" )
FILE( GLOB BUILD_SRC_CACHEADAPTER_SOURCE"${PROJECT_ROOT_DIR}/src/cpp/CacheAdapter/*.cpp" )
FILE( GLOB BUILD_SRC_KAFKAADAPTER_SOURCE"${PROJECT_ROOT_DIR}/src/cpp/KafkaProducerAdapter/*.cpp" )
#ADD_LIBRARY Adds a library target called <name> to be built from the source files listed in the command invocation.
# TARGET_LINK Specify libraries or flags to use when linking a given target.
ADD_LIBRARY( operator ${BUILD_SRC_OPERATOR_SOURCE} )
ADD_LIBRARY( CacheAdapter.cm.1.0.0 SHARED ${BUILD_SRC_CACHEADAPTER_SOURCE})
TARGET_LINK_LIBRARIES( CacheAdapter.cm.1.0.0 libBfdProto.so )
ADD_LIBRARY( KafkaProducerAdapter ${BUILD_SRC_KAFKAADAPTER_SOURCE} )
TARGET_LINK_LIBRARIES( KafkaProducerAdapter libKafkaSlice.a )
ADD_LIBRARY( stampcommon ${BUILD_SRC_RECOMMEND_SOURCE} )
TARGET_LINK_LIBRARIES( stampcommon stampSlice json log4cxx
boost_program_options ssl)
ADD_LIBRARY( rule_engine SHARED ${BUILD_SRC_RULE_SOURCE} )
TARGET_LINK_LIBRARIES( rule_engine operator python2.7 Tripod json log4cxxboost_program_options dl util pthread boost_program_options IceUtil Iceboost_thread boost_system rt m stampcommon )
#ADD_LIBRARY( rule_engine SHARED ${BUILD_SRC_RULE_SOURCE} )
#TARGET_LINK_LIBRARIES( rule_engine operator python2.7 Tripod json log4cxxboost_program_options dl util pthread stampcommon boost_program_options IceUtilIce boost_thread boost_system rt m librediscluster.a )
#ADD_EXECUTABLE( stamp ${BUILD_SRC_RABBIT_SOURCE} )
ADD_LIBRARY( stamp SHARED ${BUILD_SRC_RABBIT_SOURCE} )
TARGET_LINK_LIBRARIES( stamp stampcommon util UtilCxx IceUtil Ice IceBox
IceGrid json log4cxx boost_program_optionszookeeper_mt
CacheAdapter.cm.1.0.0 Tripod
memcached KafkaProducerAdapterrule_engine operator protobuf ssl)
#=======================================================================================
# @@service handlers@@
# =======================================================================================
# If RELATIVE flag
is specified, the results will be returned as relative paths to the given path.
SET ( HANDLER_DIR "${PROJECT_ROOT_DIR}/src/cpp/handlers" )
FILE( GLOB HANDLERS RELATIVE "${HANDLER_DIR}""${HANDLER_DIR}/[a-zA-Z]?*")
FOREACH ( handler ${HANDLERS} )
FILE( GLOB HANDLER_SOURCE
"${PROJECT_ROOT_DIR}/src/cpp/handlers/${handler}/*.cpp")
ADD_LIBRARY(${handler} SHARED"${HANDLER_SOURCE}")
TARGET_LINK_LIBRARIES(${handler}log4cxx json boost_program_options UtilCxx zookeeper_mt libBfdProto.sostampcomm)
# The PREFIX and SUFFIX properties override the default target name prefix (such as “lib”) and
suffix (such as ”.so”)
SET_TARGET_PROPERTIES(${handler}PROPERTIES PREFIX "")
ENDFOREACH ( handler )
#-----------------------------------------------------------------------------------
MESSAGE ( STATUS "**************** CMAKE Complete ****************")