1 cmake_minimum_required(VERSION 2.8)
3 set(CMAKE_BUILD_TYPE Release)
5 set (PLUGIN_CONFIG_VERSION_MAJOR 0)
6 set (PLUGIN_CONFIG_VERSION_MINOR 1)
7 set (PLUGIN_CONFIG_VERSION_PATCH 0)
9 set (PLUGIN_CONFIG_SOVERSION 1)
11 option(CPP_IMPLEMENTATION "Choose C++ implementation" OFF)
13 if(CPP_IMPLEMENTATION)
14 project(plugin-config CXX)
16 add_definitions(-DCPP_IMPLEMENTATION)
21 file(GLOB INTERFACE_INCLUDES
25 else(CPP_IMPLEMENTATION)
26 project(plugin-config C)
32 file(GLOB INTERFACE_INCLUDES
35 endif(CPP_IMPLEMENTATION)
37 #The path to the top level of the source tree.
38 message (${CMAKE_SOURCE_DIR})
40 # Add include directories to the build.
41 include_directories(${CMAKE_SOURCE_DIR}/include)
43 include(FindPkgConfig)
44 pkg_check_modules(pkgs REQUIRED
54 foreach(flag ${pkgs_CFLAGS})
55 set(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
58 # Set the compiler flags for compiling C++ sources
59 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} -std=c++0x -Wall -Wextra -fPIC")
60 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -std=gnu99 -Wall -Wextra -fPIC")
62 # macro(REMOVE_C_FLAG flag)
63 # string(REPLACE "${flag}" "-O0" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
64 # string(REPLACE "${flag}" "-O0" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
66 # REMOVE_C_FLAG("-O2")
67 # REMOVE_C_FLAG("-O3")
69 set(EXTRA_LIBS ${EXTRA_LIBS} ${pkgs_LDFLAGS})
71 set(SHARED_LIBRARY ${PROJECT_NAME})
72 add_library(${SHARED_LIBRARY} SHARED ${SOURCES})
74 #Link a target to given libraries.
75 target_link_libraries(${SHARED_LIBRARY} ${EXTRA_LIBS})
77 set_target_properties(${SHARED_LIBRARY} PROPERTIES VERSION ${PLUGIN_CONFIG_VERSION_MAJOR}.${PLUGIN_CONFIG_VERSION_MINOR} SOVERSION ${PLUGIN_CONFIG_SOVERSION})
79 # Add an executable to the project using the specified source files.
81 #Link a target to given libraries.
82 target_link_libraries(${EXECUTABLE} ${SHARED_LIBRARY} ${EXTRA_LIBS})
85 set(HOME_DIR /home/${USER})
87 # Provides an option that the user can optionally select.
88 option(INSTALL_INTO_HOME_DIR "Install targets into home directory (for test pusrposes)" OFF)
89 if(INSTALL_INTO_HOME_DIR)
90 # Install directory used by install
91 set(CMAKE_INSTALL_PREFIX ${HOME_DIR}/pluginconfig)
92 endif(INSTALL_INTO_HOME_DIR)
94 #Generate ex-04.pc file from ex-04.pc.in located in the top level source tree subdirectory pkgconfig.
96 "${CMAKE_SOURCE_DIR}/pkgconfig/${PROJECT_NAME}.pc.in"
97 "${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pc"
101 # Generate uninstall.cmake file from uninstall.cmake.in located in the top level source tree directory.
103 "${CMAKE_CURRENT_SOURCE_DIR}/uninstall.cmake.in"
104 "${CMAKE_CURRENT_BINARY_DIR}/uninstall.cmake"
107 # Add custom command uninstall intended to unistall previously installed files
108 # ( process ${CMAKE_CURRENT_BINARY_DIR}/uninstall.cmake)
109 add_custom_target(uninstall
110 COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/uninstall.cmake)
112 install(TARGETS ${EXECUTABLE} RUNTIME DESTINATION bin)
113 install(TARGETS ${SHARED_LIBRARY} DESTINATION lib)
114 install(FILES ${INTERFACE_INCLUDES} DESTINATION include)
115 install(FILES "${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pc" DESTINATION lib/pkgconfig)
116 #install(FILES "${CMAKE_SOURCE_DIR}/config/pluginmanager.ini" DESTINATION /usr/share/cloudbox/config)
118 # build a CPack driven installer package
119 include (InstallRequiredSystemLibraries)
120 set (CPACK_RESOURCE_FILE_LICENSE
121 "${CMAKE_CURRENT_SOURCE_DIR}/License.txt")
122 set (CPACK_PACKAGE_VERSION_MAJOR "${PLUGIN_CONFIG_VERSION_MAJOR}")
123 set (CPACK_PACKAGE_VERSION_MINOR "${PLUGIN_CONFIG_VERSION_MINOR}")
124 set (CPACK_PACKAGE_VERSION_PATCH "${PLUGIN_CONFIG_VERSION_PATCH}")
125 set (CPACK_SYSTEM_NAME ${CMAKE_LIBRARY_ARCHITECTURE})
126 set (CPACK_GENERATOR "DEB")
127 set (CPACK_DEBIAN_PACKAGE_MAINTAINER "Yongjin Kim") #required
128 set (CPACK_PACKAGE_CONTACT "youth.kim@samsung.com") #required