Skip to content

Commit

Permalink
Merged wigh ign-math
Browse files Browse the repository at this point in the history
  • Loading branch information
nkoenig committed Jul 31, 2017
1 parent 980fbe8 commit d9a5e62
Show file tree
Hide file tree
Showing 21 changed files with 473 additions and 239 deletions.
2 changes: 1 addition & 1 deletion AUTHORS
Original file line number Diff line number Diff line change
@@ -1 +1 @@
OSRFoundation
Open Robotics
131 changes: 81 additions & 50 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,24 +1,37 @@
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)

set(IGN_PROJECT_NAME "<project-name>")

project (ignition-${IGN_PROJECT_NAME})
string (TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWER)
string (TOUPPER ${PROJECT_NAME} PROJECT_NAME_UPPER)
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)

# Set the project name and version number here
set(IGN_PROJECT_NAME "project_name")
set (PROJECT_MAJOR_VERSION 0)
set (PROJECT_MINOR_VERSION 1)
set (PROJECT_PATCH_VERSION 0)

#################################################
# Only change values below here if you know
# what you're doing
#################################################

project (ignition-${IGN_PROJECT_NAME}${PROJECT_MAJOR_VERSION})

set(PROJECT_NAME_NO_VERSION "ignition-${IGN_PROJECT_NAME}")
string (TOLOWER ${PROJECT_NAME_NO_VERSION} PROJECT_NAME_NO_VERSION_LOWER)
string (TOUPPER ${PROJECT_NAME_NO_VERSION} PROJECT_NAME_NO_VERSION_UPPER)
string (TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWER)
string (TOUPPER ${PROJECT_NAME} PROJECT_NAME_UPPER)
set(PROJECT_EXPORT_NAME ${PROJECT_NAME_LOWER})
set(PROJECT_LIBRARY_TARGET_NAME ${PROJECT_NAME_LOWER})

set (PROJECT_VERSION ${PROJECT_MAJOR_VERSION}.${PROJECT_MINOR_VERSION})
set (PROJECT_VERSION_FULL ${PROJECT_MAJOR_VERSION}.${PROJECT_MINOR_VERSION}.${PROJECT_PATCH_VERSION})
set (PROJECT_VERSION_FULL
${PROJECT_MAJOR_VERSION}.${PROJECT_MINOR_VERSION}.${PROJECT_PATCH_VERSION})

message (STATUS "${PROJECT_NAME} version ${PROJECT_VERSION_FULL}")
message (STATUS "${PROJECT_NAME_NO_VERSION} version ${PROJECT_VERSION_FULL}")

set (project_cmake_dir ${PROJECT_SOURCE_DIR}/cmake
CACHE PATH "Location of CMake scripts")

include (${project_cmake_dir}/Utils.cmake)
include (CMakePackageConfigHelpers)

########################################
# Package Creation:
Expand Down Expand Up @@ -91,9 +104,10 @@ if(LD_LIBRARY_PATH)
endif()


set (INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}/ignition")
set (INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}")
set (INCLUDE_INSTALL_DIR_POSTFIX "ignition/${IGN_PROJECT_NAME}${PROJECT_MAJOR_VERSION}")
set (INCLUDE_INSTALL_DIR_FULL "${INCLUDE_INSTALL_DIR}/${INCLUDE_INSTALL_DIR_POSTFIX}")
set (LIB_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR})
set (LIB_INSTALL_DIR_ARCH_INDEPENDENT "lib/")
set (BIN_INSTALL_DIR ${CMAKE_INSTALL_BINDIR})

set (USE_FULL_RPATH OFF CACHE BOOL "Set to true to enable full rpath")
Expand Down Expand Up @@ -167,26 +181,23 @@ endif()
unset (CMAKE_C_FLAGS_ALL CACHE)
unset (CMAKE_CXX_FLAGS CACHE)

# USE_HOST_CFLAGS (default TRUE)
# Will check building host machine for proper cflags
if(NOT DEFINED USE_HOST_CFLAGS OR USE_HOST_CFLAGS)
message(STATUS "Enable host CFlags")
include (${project_cmake_dir}/HostCFlags.cmake)
endif()

# USE_UPSTREAM_CFLAGS (default TRUE)
# Will use predefined ignition developers cflags
if(NOT DEFINED USE_UPSTREAM_CFLAGS OR USE_UPSTREAM_CFLAGS)
message(STATUS "Enable upstream CFlags")
include(${project_cmake_dir}/DefaultCFlags.cmake)
# Check if warning options are avaliable for the compiler and return WARNING_CXX_FLAGS variable
# MSVC generates tons of warnings on gtest code.
# Recommended to use /W4 instead of /Wall
if (MSVC)
set(WARN_LEVEL "/W4")
else()
set(WARN_LEVEL "-Wall")
endif()

# Check if warning options are avaliable for the compiler and return WARNING_CXX_FLAGS variable
filter_valid_compiler_warnings(-Wall -Wextra -Wno-long-long
filter_valid_compiler_warnings(${WARN_LEVEL} -Wextra -Wno-long-long
-Wno-unused-value -Wno-unused-value -Wno-unused-value -Wno-unused-value
-Wfloat-equal -Wshadow -Winit-self -Wswitch-default
-Wmissing-include-dirs -pedantic)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}${WARNING_CXX_FLAGS}")
if (DEFINED EXTRA_CMAKE_CXX_FLAGS)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CMAKE_CXX_FLAGS}")
endif()

#################################################
# OS Specific initialization
Expand Down Expand Up @@ -231,16 +242,12 @@ else (build_errors)

########################################
# Write the config.hh file
configure_file (${project_cmake_dir}/config.hh.in
${PROJECT_BINARY_DIR}/include/ignition/${IGN_PROJECT_NAME}/config.hh)
configure_file ("${project_cmake_dir}/config.hh.in"
"${PROJECT_BINARY_DIR}/include/ignition/${IGN_PROJECT_NAME}/config.hh")
ign_install_includes(
${IGN_PROJECT_NAME}${PROJECT_MAJOR_VERSION}/ignition/${IGN_PROJECT_NAME}
${PROJECT_BINARY_DIR}/include/ignition/${IGN_PROJECT_NAME}/config.hh)
"${INCLUDE_INSTALL_DIR_POSTFIX}/ignition/${IGN_PROJECT_NAME}"
"${PROJECT_BINARY_DIR}/include/ignition/${IGN_PROJECT_NAME}/config.hh")

include_directories(
${PROJECT_SOURCE_DIR}/include
${PROJECT_BINARY_DIR}/include
)
link_directories(${PROJECT_BINARY_DIR}/src)

if (DEFINED CMAKE_CXX_FLAGS)
Expand All @@ -260,25 +267,35 @@ else (build_errors)

########################################
# Make the package config files
configure_file(
${CMAKE_SOURCE_DIR}/cmake/pkgconfig/ignition.in
${CMAKE_CURRENT_BINARY_DIR}/cmake/pkgconfig/${PROJECT_NAME_LOWER}.pc @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cmake/pkgconfig/${PROJECT_NAME_LOWER}.pc
DESTINATION ${LIB_INSTALL_DIR_ARCH_INDEPENDENT}/pkgconfig
COMPONENT pkgconfig)
set (pkgconfig_files ${PROJECT_NAME_NO_VERSION_LOWER})

foreach (pkgconfig ${pkgconfig_files})
configure_file(${CMAKE_SOURCE_DIR}/cmake/pkgconfig/${pkgconfig}.in
${CMAKE_CURRENT_BINARY_DIR}/cmake/pkgconfig/${pkgconfig}${PROJECT_MAJOR_VERSION}.pc @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cmake/pkgconfig/${pkgconfig}${PROJECT_MAJOR_VERSION}.pc
DESTINATION ${LIB_INSTALL_DIR}/pkgconfig COMPONENT pkgconfig)
endforeach()

########################################
# Make the cmake config files
set(PKG_NAME ${PROJECT_NAME_UPPER})
set(PKG_LIBRARIES ${PROJECT_NAME_LOWER}${PROJECT_MAJOR_VERSION})
set(cmake_conf_file "${PROJECT_NAME_LOWER}${PROJECT_MAJOR_VERSION}-config.cmake")
set(cmake_conf_version_file "${PROJECT_NAME_LOWER}${PROJECT_MAJOR_VERSION}-config-version.cmake")
set(PKG_NAME ${PROJECT_NAME_NO_VERSION_UPPER})
set(cmake_conf_file "${PROJECT_NAME_LOWER}-config.cmake")
set(cmake_conf_version_file "${PROJECT_NAME_LOWER}-config-version.cmake")
set(cmake_targets_file "${PROJECT_NAME_LOWER}-targets.cmake")

set(PKG_DEPENDS)

configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/${PROJECT_NAME_LOWER}-config.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/${cmake_conf_file}" @ONLY)
if(WIN32 AND NOT CYGWIN)
set(CMAKE_CONFIG_INSTALL_DIR CMake)
else()
set(CMAKE_CONFIG_INSTALL_DIR ${LIB_INSTALL_DIR}/cmake/${PROJECT_NAME_LOWER}/)
endif()

configure_package_config_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/ignition-config.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/${cmake_conf_file}"
PATH_VARS LIB_INSTALL_DIR INCLUDE_INSTALL_DIR_FULL
INSTALL_DESTINATION ${CMAKE_CONFIG_INSTALL_DIR})

# Use write_basic_package_version_file to generate a ConfigVersion file that
# allow users of gazebo to specify the API or version to depend on
Expand All @@ -293,16 +310,30 @@ else (build_errors)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/${cmake_conf_file}
${CMAKE_CURRENT_BINARY_DIR}/${cmake_conf_version_file}
DESTINATION ${LIB_INSTALL_DIR}/cmake/${PROJECT_NAME_LOWER}${PROJECT_MAJOR_VERSION}/ COMPONENT cmake)
DESTINATION ${CMAKE_CONFIG_INSTALL_DIR} COMPONENT cmake)

# Create *-targets.cmake file for build directory
# TODO: keep this instruction until we depend on CMake 3
# then change the first line from TARGETS ...
# to EXPORT ... to match the format used in install(EXPORT
export(TARGETS ${PROJECT_LIBRARY_TARGET_NAME}
FILE ${CMAKE_BINARY_DIR}/${cmake_targets_file})

# Install *-targets.cmake file
install(EXPORT ${PROJECT_EXPORT_NAME}
DESTINATION ${CMAKE_CONFIG_INSTALL_DIR}
FILE ${cmake_targets_file})


########################################
# If present, load platform-specific build hooks. This system is used,
# for example, by the Ubuntu overlay, to arrange for installation of
# Ubuntu-specific application-launching configuration.
# for example, by the Ubuntu overlay, to
# arrange for installation of Ubuntu-specific application-launching
# configuration.
if (EXISTS ${PROJECT_SOURCE_DIR}/cmake/packager-hooks/CMakeLists.txt)
message(STATUS "Loading packager build hooks from cmake/packager-hooks")
add_subdirectory(cmake/packager-hooks)
endif()

message(STATUS "Configuration successful. Type make to compile ${PROJECT_NAME_LOWER}")
message(STATUS "Configuration successful.")
endif(build_errors)
30 changes: 12 additions & 18 deletions cmake/DefaultCFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,15 @@ set (CMAKE_CXX_FLAGS_COVERAGE "${CMAKE_C_FLAGS_COVERAGE} -fno-elide-constructors

#####################################
# Set all the global build flags
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE_UPPERCASE}}")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE_UPPERCASE}} -std=c++11")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_LINK_FLAGS_${CMAKE_BUILD_TYPE_UPPERCASE}}")
set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_LINK_FLAGS_${CMAKE_BUILD_TYPE_UPPERCASE}}")
set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_LINK_FLAGS_${CMAKE_BUILD_TYPE_UPPERCASE}}")

# Compiler-specific C++11 activation.
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
execute_process(
COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
if (NOT (GCC_VERSION VERSION_GREATER 4.7))
message(FATAL_ERROR "${PROJECT_NAME} requires g++ 4.8 or greater.")
endif ()
elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
else ()
message(FATAL_ERROR "Your C++ compiler does not support C++11.")
endif ()
if (UNIX)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE_UPPERCASE}}")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE_UPPERCASE}}")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_LINK_FLAGS_${CMAKE_BUILD_TYPE_UPPERCASE}}")
set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_LINK_FLAGS_${CMAKE_BUILD_TYPE_UPPERCASE}}")
set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_LINK_FLAGS_${CMAKE_BUILD_TYPE_UPPERCASE}}")
# Add visibility in UNIX
check_gcc_visibility()
if (GCC_SUPPORTS_VISIBILITY)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
endif()
endif()
4 changes: 2 additions & 2 deletions cmake/DissectVersion.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Find version components
STRING (REGEX REPLACE "^([0-9]+).*" "\\1" PROJECT_MAJOR_VERSION "${PROJECT_VERSION_FULL}")
STRING (REGEX REPLACE "^[0-9]+\\.([0-9]+).*" "\\1" PROJECT_MINOR_VERSION "${PROJECT_VERSION_FULL}")
STRING (REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" IGNITION_REVISION_VERSION ${PROJECT_VERSION_FULL})
STRING (REGEX REPLACE "^[0-9]+\\.[0-9]+\\.[0-9]+(.*)" "\\1" IGNITION_CANDIDATE_VERSION ${PROJECT_VERSION_FULL})
STRING (REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" PROJECT_REVISION_VERSION ${PROJECT_VERSION_FULL})
STRING (REGEX REPLACE "^[0-9]+\\.[0-9]+\\.[0-9]+(.*)" "\\1" PROJECT_CANDIDATE_VERSION ${PROJECT_VERSION_FULL})
Loading

0 comments on commit d9a5e62

Please sign in to comment.