2 #############################################
4 # Step 1. Set Variable and Build Dependency
7 # set a name for the entire project
11 SET(EXENAME "${PROJECT_NAME}-agent")
12 SET(BINDIR "${PREFIX}/bin")
13 SET(DUMMY_SRC_DIR "${CMAKE_SOURCE_DIR}/src/agent")
14 SET(DUMMY_COMPONETS "main")
16 # checks for build dependency modules : a pkg-config module for CMake
17 INCLUDE(FindPkgConfig)
18 pkg_check_modules(LPKGS REQUIRED
25 #############################################
27 # Step 2. Set Compile Environment
30 # set extra cflags from build dependency
31 STRING(REPLACE ";" " " EXTRA_CFLAGS "${LPKGS_CFLAGS}")
33 # find all source files in a directory.
34 FOREACH(DUMMY_COMPONET ${DUMMY_COMPONETS})
35 AUX_SOURCE_DIRECTORY(${DUMMY_SRC_DIR}/${DUMMY_COMPONET} SRCS)
36 ENDFOREACH(DUMMY_COMPONET)
38 # add internal include directories to the build.
41 ADD_DEFINITIONS("-DGLIB_VERSION_MIN_REQUIRED=(2<<16|32<<8) ")
43 #############################################
45 # Step 3. Set Link Environment
48 # add an executable to the project using the specified source files.
49 ADD_EXECUTABLE(${EXENAME} ${SRCS})
51 # link a target to given libraries.
52 TARGET_LINK_LIBRARIES(${EXENAME} ${LPKGS_LIBRARIES})
54 # sets additional compiler flags used to build sources within the target.
55 SET_TARGET_PROPERTIES(${EXENAME} PROPERTIES COMPILE_FLAGS ${EXTRA_CFLAGS})
57 #############################################
59 # Step 4. Install packages
62 # install executable file
63 INSTALL(TARGETS ${EXENAME} DESTINATION ${BINDIR})
65 # install dummy configuration files
66 INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/dummy-cfg DESTINATION /usr/share)