From 44a53c75f4de4ac612f666835abceca49abbbff6 Mon Sep 17 00:00:00 2001 From: Krzysztof Opasiak Date: Wed, 30 Jul 2014 09:35:28 +0200 Subject: [PATCH] gt: cmake: Rewrite CMake scripts Change-Id: I32f0f980b2f0fb67a3ea4af889480d87317ca015 Signed-off-by: Krzysztof Opasiak --- source/CMakeLists.txt | 46 +++++++++++++++++++++++++++++++++------------- source/base/CMakeLists.txt | 11 +++++------ 2 files changed, 38 insertions(+), 19 deletions(-) diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 28e0a29..9903c66 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -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}) + diff --git a/source/base/CMakeLists.txt b/source/base/CMakeLists.txt index 0ba8624..612a037 100644 --- a/source/base/CMakeLists.txt +++ b/source/base/CMakeLists.txt @@ -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 -- 2.7.4