Skip to content

Commit

Permalink
CMake cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
jgoppert committed Mar 1, 2012
1 parent cac3679 commit ce4ed93
Show file tree
Hide file tree
Showing 6 changed files with 162 additions and 147 deletions.
169 changes: 142 additions & 27 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,111 @@ project (mavlink NONE)

# settings
cmake_minimum_required (VERSION 2.8.2)
set(APPLICATION_NAME ${PROJECT_NAME})
set(PROJECT_CONTACT_VENDOR mavlink)
set(APPLICATION_VERSION_MAJOR "1")
set(APPLICATION_VERSION_MINOR "0")
set(APPLICATION_VERSION_PATCH "0")
set(APPLICATION_VERSION "${APPLICATION_VERSION_MAJOR}.${APPLICATION_VERSION_MINOR}.${APPLICATION_VERSION_PATCH}")
set(LIBRARY_SOVERSION "0.0.0")
set(PROJECT_VERSION_MAJOR "1")
set(PROJECT_VERSION_MINOR "0")
set(PROJECT_VERSION_PATCH "0")
set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
set(PROJECT_CONTACT_EMAIL http://groups.google.com/group/mavlink)
set(PROJECT_CONTACT_VENDOR mavlink)
set(LIBRARY_VERSION ${PROJECT_VERSION})
set(LIBRARY_SOVERSION "0.0.0")

# modules
set(CMAKE_MODULE_PATH
${CMAKE_SOURCE_DIR}/cmake
${CMAKE_SOURCE_DIR}/cmake/arkcmake
)
# third party
# none required

# optoins
option(WITH_TESTS "Build test programs." OFF)
option(WITH_BUILD_DEPS "Build dependencies." ON)
option(WITH_BUILD_STATIC "Build preferring static linking." ON)

# use common setup
include(CommonSetup)
set(LIBRARY_VERSION ${APPLICATION_VERSION})
# variables
set(ROOT_THREAD TRUE CACHE INTERNAL "Is this the top level of the recursion?")
set(INSTALLED_TARGETS "")

# modules
#include(CTest)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_SOURCE_DIR}/cmake/arkcmake)
#include(CheckIncludeFiles)
#include(CheckFunctionExists)
#include(CheckSymbolExists)
#include(CheckLibraryExists)
#include(CheckTypeSize)
#include(CheckPrototypeExists)
#include(CheckCXXSourceCompiles)
#include(CheckCSourceCompiles)
include(ExternalProject)

# cpack
include(CPackPackage)
# spawn new cmake to build deps
if (WITH_BUILD_DEPS AND ROOT_THREAD)
execute_process(COMMAND ${CMAKE_COMMAND} "${CMAKE_SOURCE_DIR}"
"-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}"
"-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}"
"-DWITH_BUILD_DEPS=${WITH_BUILD_STATIC}"
"-DWITH_BUILD_STATIC=${WITH_BUILD_STATIC}"
"-DWITH_TESTS=${WITH_ARKOSG}"
"-DROOT_THREAD=FALSE"
RESULT_VARIABLE ERROR)
if (ERROR)
message(FATAL_ERROR "error, recursing loop returned error code: ${ERROR}")
endif()
message("** Making dependencies")
execute_process(COMMAND ${CMAKE_MAKE_PROGRAM} "-j4" "-f${CMAKE_BINARY_DIR}/Makefile")
message("** Configuring ${PROJECT_NAME}")
endif()

# find packages
find_package(PythonInterp)
# external projects find path
if(NOT EP_BASE_DIR)
set(EP_BASE_DIR "${CMAKE_BINARY_DIR}/CMakeExternals")
endif()
list(APPEND CMAKE_FIND_ROOT_PATH ${EP_BASE_DIR})

# settings
option(BUILD_TEST "Build test programs." OFF)
# prefer static packages if building static library
message("** Finding libraries")
if (WITH_BUILD_STATIC)
# prefer static libs
if(WIN32)
set(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
else()
set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
endif()
endif()

# find libraries with cmake modules
find_package(PythonInterp)

# enable languages
if (BUILD_TEST)
if (WITH_TESTS)
enable_language(C)
enable_language(CXX)
include(DefineCompilerFlags)
endif()

# build dependencies
if (WITH_BUILD_DEPS AND (NOT ROOT_THREAD) )
message("** Configuring dependencies")

# add external projects

# none required currently

set(CMAKE_DEFAULT_ARGS
-DEP_BASE_DIR=${EP_BASE_DIR}
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
)

# terminate non root cmake thread
return()
endif()

# configure
#check_include_files(string.h HAVE_STRING_H)
#check_function_exists(memcopy HAVE_MEMCOPY)
#check_symbol_exists(LC_MESSAGES "locale.h" HAVE_LC_MESSAGES)
#check_library_exists(arkosg attachNode "" HAVE_ARKOSG)

# config files
configure_file(config.h.in config.h)

# mavlink generation
macro(generateMavlink version definitions)
foreach(definition ${definitions})
Expand Down Expand Up @@ -92,13 +158,62 @@ if (BUILD_TEST)
endif()

# install files
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/ DESTINATION include/${PROJECT_NAME} FILES_MATCHING PATTERN "*.h")
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/ DESTINATION include/${PROJECT_NAME} COMPONENT dev FILES_MATCHING PATTERN "*.h")

# install
install(TARGETS ${INSTALLED_TARGETS}
RUNTIME DESTINATION "bin" COMPONENT Runtime
LIBRARY DESTINATION "lib" COMPONENT Runtime
ARCHIVE DESTINATION "lib" COMPONENT Dev
BUNDLE DESTINATION "/Applications" COMPONENT Runtime
FRAMEWORK DESTINATION "/Library/Frameworks" COMPONENT Runtime
# where to put files on non-mac computers, mac overrides and uses default
PRIVATE_HEADER DESTINATION "include/${PROJECT_NAME}" COMPONENT Runtime
PUBLIC_HEADER DESTINATION "include/${PROJECT_NAME}" COMPONENT Runtime
RESOURCE DESTINATION "share/${PROJECT_NAME}" COMPONENT Runtime
)

# install external projects, if built
if (EXISTS ${EP_BASE_DIR}/${CMAKE_INSTALL_PREFIX}/)
install(DIRECTORY ${EP_BASE_DIR}/${CMAKE_INSTALL_PREFIX}/ DESTINATION ${CMAKE_INSTALL_PREFIX} COMPONENT Runtime)
endif()

### packaging

# apple bundle icon
if (APPLE)
# set how it shows up in Info.plist
set(MACOSX_BUNDLE_ICON_FILE mavlink.icns)
# set where in the bundle to put the icns file
set_source_files_properties(cmake/mavlink.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
# include the icns file in the target
#list(APPEND MAVLINKGUI_SRCS cmake/mavlink.icns)
endif()

# set NSIS image
if (WIN32)
set(CPACK_PACKAGE_ICON "${CMAKE_SOURCE_DIR}/cmake/mavlink.bmp")
endif()

# add file extensions and set resource files
configure_file("COPYING" "COPYING.txt" COPYONLY)
configure_file("README" "README.txt" COPYONLY)
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_BINARY_DIR}/COPYING.txt")
set(CPACK_RESOURCE_FILE_README "${CMAKE_BINARY_DIR}/README.txt")
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CPACK_RESOURCE_FILE_README}")
set(CPACK_RESOURCE_FILE_WELCOME "${CMAKE_SOURCE_DIR}/cmake/WELCOME.txt")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "mavlink message marshalling library")
set(CPACK_PACKAGE_VENDOR ${PROJECT_CONTACT_VENDOR})
set(CPACK_PACKAGE_CONTACT "${PROJECT_CONTACT_EMAIL}")
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
set(CPACK_SET_DESTDIR TRUE)
set(CPACK_COMPONENTS_GROUPING "ALL_COMPONENTS_IN_ONE")
include(CPack)

# pkgconfig
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc)
configure_file(pc.in ${PROJECT_NAME}.pc)
install(FILES
${PROJECT_BINARY_DIR}/${PROJECT_NAME}.pc
DESTINATION lib/pkgconfig
DESTINATION "lib/pkgconfig" COMPONENT Dev
)

# vim:sw=4:ts=4:expandtab
82 changes: 0 additions & 82 deletions cmake/CPackPackage.cmake

This file was deleted.

36 changes: 0 additions & 36 deletions cmake/MacOSXBundleInfo.plist.in

This file was deleted.

2 changes: 0 additions & 2 deletions cmake/WELCOME.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
Welcome to installation. This program will guide you through the installation of this software.

Installing this software requires administrator access. If you do not have administrator access to this computer, we recommend downloading the bundle version.
20 changes: 20 additions & 0 deletions config.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/************************** DIRECTORIES *************************/
#cmakedefine PROJECT_NAME "@PROJECT_NAME@"

/************************** HEADER FILES *************************/
#cmakedefine HAVE_STRING_H 1

/*************************** FUNCTIONS ***************************/
#cmakedefine HAVE_MEMCOPY 1

/*************************** LIBRARIES ***************************/

/**************************** OPTIONS ****************************/

#cmakedefine WITH_TESTS 1

/*************************** ENDIAN *****************************/

/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
significant byte first (like Motorola and SPARC, unlike Intel). */
#cmakedefine WORDS_BIGENDIAN 1
File renamed without changes.

0 comments on commit ce4ed93

Please sign in to comment.