gt: cmake: Rewrite CMake scripts
authorKrzysztof Opasiak <k.opasiak@samsung.com>
Wed, 30 Jul 2014 07:35:28 +0000 (09:35 +0200)
committerKrzysztof Opasiak <k.opasiak@samsung.com>
Wed, 30 Jul 2014 07:35:28 +0000 (09:35 +0200)
Change-Id: I32f0f980b2f0fb67a3ea4af889480d87317ca015
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
source/CMakeLists.txt
source/base/CMakeLists.txt

index 28e0a29..9903c66 100644 (file)
@@ -1,28 +1,48 @@
 cmake_minimum_required(VERSION 2.8)
 
 #project name
-project (gadget-tool)
+PROJECT(gt)
 
-INCLUDE_DIRECTORIES( ${gadget-tool_SOURCE_DIR}/base/include )
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/base/include)
 
-SET(CMAKE_C_FLAGS -g)
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+SET(BINDIR "${PREFIX}/bin")
 
-add_subdirectory(config)
-add_subdirectory(function)
-add_subdirectory(gadget)
-add_subdirectory(settings)
-add_subdirectory(udc)
-add_subdirectory(base)
+ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"")
 
-SET( MAIN_SRC main.c)
+SET(PKG_MODULES
+        libusbg
+)
 
-add_executable( gt ${MAIN_SRC})
+INCLUDE(FindPkgConfig)
+pkg_check_modules(pkgs REQUIRED ${PKG_MODULES})
 
-target_link_libraries( gt
+FOREACH(flag ${pkgs_CFLAGS})
+        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -g -Wall")
+
+ADD_SUBDIRECTORY(config)
+ADD_SUBDIRECTORY(function)
+ADD_SUBDIRECTORY(gadget)
+ADD_SUBDIRECTORY(settings)
+ADD_SUBDIRECTORY(udc)
+ADD_SUBDIRECTORY(base)
+
+SET(MAIN_SRC main.c)
+
+ADD_EXECUTABLE(${PROJECT_NAME} ${MAIN_SRC})
+
+TARGET_LINK_LIBRARIES( gt
        base
        udc
        config
        function
        gadget
        settings
-       )
\ No newline at end of file
+       ${pkgs_LDFLAGS}
+)
+
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${BINDIR})
+
index 0ba8624..612a037 100644 (file)
@@ -1,10 +1,9 @@
-
 INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR}/include
-                       ${gadget-tool_SOURCE_DIR}/udc/include
-                       ${gadget-tool_SOURCE_DIR}/config/include
-                       ${gadget-tool_SOURCE_DIR}/function/include
-                       ${gadget-tool_SOURCE_DIR}/gadget/include
-                       ${gadget-tool_SOURCE_DIR}/settings/include )
+                       ${CMAKE_SOURCE_DIR}/udc/include
+                       ${CMAKE_SOURCE_DIR}/config/include
+                       ${CMAKE_SOURCE_DIR}/function/include
+                       ${CMAKE_SOURCE_DIR}/gadget/include
+                       ${CMAKE_SOURCE_DIR}/settings/include )
 
 SET( BASE_SRC
        ${CMAKE_CURRENT_SOURCE_DIR}/src/command.c