Permalink
Browse files

First adaption of cmake-init 2.0 (daca2d9bc86b4fe594d0acf0f05775005dc…

…41224)
  • Loading branch information...
scheibel committed Dec 21, 2015
1 parent a1c34c4 commit f979fd3ba15061cfc00014486c6931048feb9bac
Showing 371 changed files with 155,195 additions and 1,920 deletions.
View
@@ -1,198 +1,170 @@
-cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR)
+#
+# CMake options
+#
+
+# CMake version
+cmake_minimum_required(VERSION 3.2 FATAL_ERROR)
+
+# Include cmake modules
+list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
+include(GenerateExportHeader)
+include(ExternalProject)
+include(WriteCompilerDetectionHeader)
+include(cmake/GetGitRevisionDescription.cmake)
+include(cmake/Custom.cmake)
+
+# Set policies
+set_policy(CMP0028 NEW) # ENABLE CMP0028: Double colon in target name means ALIAS or IMPORTED target.
+set_policy(CMP0054 NEW) # ENABLE CMP0054: Only interpret if() arguments as variables or keywords when unquoted.
+set_policy(CMP0042 NEW) # ENABLE CMP0042: MACOSX_RPATH is enabled by default.
+set_policy(CMP0063 NEW) # ENABLE CMP0063: Honor visibility properties for all target types.
+#
# Project description and (meta) information
+#
+# Get git revision
+get_git_head_revision(GIT_REFSPEC GIT_SHA1)
+string(SUBSTRING "${GIT_SHA1}" 0 12 GIT_REV)
+
+# Meta information about the project
set(META_PROJECT_NAME "glbinding")
set(META_PROJECT_DESCRIPTION "A C++ binding for the OpenGL API, generated using the gl.xml specification.")
+set(META_AUTHOR_ORGANIZATION "CG Internals GmbH")
+set(META_AUTHOR_DOMAIN "https://github.com/cginternals/cmake-init/")
+set(META_AUTHOR_MAINTAINER "opensource@cginternals.com")
set(META_VERSION_MAJOR "1")
-set(META_VERSION_MINOR "1")
+set(META_VERSION_MINOR "0")
set(META_VERSION_PATCH "0")
+set(META_VERSION_REVISION "${GIT_REV}")
set(META_VERSION "${META_VERSION_MAJOR}.${META_VERSION_MINOR}.${META_VERSION_PATCH}")
-set(META_AUTHOR_ORGANIZATION "cginternals")
-set(META_AUTHOR_DOMAIN "https://github.com/cginternals/glbinding")
-set(META_AUTHOR_MAINTAINER "info@cginternals.com")
-
-string(TOUPPER ${META_PROJECT_NAME} META_PROJECT_NAME_UPPER)
-
-
-# Limit supported configuration types
-set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "Limited Configs" FORCE)
-
-# Set project name and type (C/C++)
-project(${META_PROJECT_NAME} C CXX)
+set(META_NAME_VERSION "${META_PROJECT_NAME} v${META_VERSION} (${META_VERSION_REVISION})")
-# Configuration options
+#
+# Project configuration options
+#
-option(OPTION_PORTABLE_INSTALL "Install into a self-contained directory" OFF)
-option(OPTION_BUILD_STATIC "Build static libraries" OFF)
-option(OPTION_BUILD_TESTS "Build tests (if gmock and gtest are found)" ON)
-option(OPTION_BUILD_TOOLS "Build tools" OFF)
-option(OPTION_BUILD_EXAMPLES "Build examples" OFF)
+# Project options
+option(BUILD_SHARED_LIBS "Build shared instead of static libraries." ON)
+option(OPTION_SELF_CONTAINED "Create a self-contained install with all dependencies." OFF)
+option(OPTION_BUILD_TESTS "Build tests." ON)
+option(OPTION_BUILD_DOCS "Build documentation." OFF)
+option(OPTION_BUILD_EXAMPLES "Build examples." OFF)
+option(OPTION_BUILD_TOOLS "Build tools." ON)
+option(OPTION_EXTENSIVE_META "Provide extensive meta information for bidirectional conversion between String and OpenGL types" ON)
-option(OPTION_EXTENSIVE_META "Provide extensive meta information for bidirectional conversion between String and OpenGL types" ON)
-if(OPTION_BUILD_STATIC)
- set(BUILD_SHARED_LIBS OFF)
- message("Note: ${META_PROJECT_NAME_UPPER}_STATIC needs to be defined for static linking.")
-else()
- set(BUILD_SHARED_LIBS ON)
-endif()
+#
+# Declare project
+#
+# Generate folders for IDE targets (e.g., VisualStudio solutions)
+set_property(GLOBAL PROPERTY USE_FOLDERS ON)
+set(IDE_FOLDER "")
-# CMake configuration
-
-# Include cmake modules from ./cmake
-set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
+# Declare project
+project(${META_PROJECT_NAME} C CXX)
# Set output directories
-set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
-set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
-set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
+set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
+set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
+# Create version file
+file(WRITE "${PROJECT_BINARY_DIR}/VERSION" "${META_NAME_VERSION}")
-# Generate folders for IDE targets (e.g., VisualStudio solutions)
-set_property(GLOBAL PROPERTY USE_FOLDERS ON)
-set(IDE_FOLDER "") # Put projects in root folder by default
-# Include custom cmake functions
-include(cmake/Custom.cmake)
-include(cmake/GitRevision.cmake)
+#
+# Compiler settings and options
+#
+include(cmake/CompileOptions.cmake)
-# Platform and architecture
-# Architecture (32/64 bit)
-set(X64 OFF)
-if(CMAKE_SIZEOF_VOID_P EQUAL 8)
- set(X64 ON)
-endif()
+#
+# Deployment/installation setup
+#
-# Setup platform specifics (compile flags, etc., ...)
+# Get project name
+set(project ${META_PROJECT_NAME})
-# This policy was introduced in 3.0.0 and does not allow for COMPILER_DEFINITIONS_<Config>,
-# anymore, but instead requires generator expressions like $<CONFIG:Debug> ...
-# For now the current compile-flag, -definitions, and linker-flags setup shall remain as is.
-if(POLICY CMP0043)
- cmake_policy(SET CMP0043 OLD)
+# Check for system dir install
+set(SYSTEM_DIR_INSTALL FALSE)
+if("${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr" OR "${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr/local")
+ set(SYSTEM_DIR_INSTALL TRUE)
endif()
-if(MSVC)
- include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/PlatformWindowsMSVC.cmake)
-elseif(WIN32 AND CMAKE_COMPILER_IS_GNUCXX)
- include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/PlatformWindowsGCC.cmake)
-elseif(APPLE)
- include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/PlatformMacOS.cmake)
-elseif(UNIX AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
- include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/PlatformLinuxClang.cmake)
-elseif(UNIX)
- include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/PlatformLinuxGCC.cmake)
+# Installation paths
+if(UNIX AND SYSTEM_DIR_INSTALL)
+ # Install into the system (/usr/bin or /usr/local/bin)
+ set(INSTALL_ROOT "share/${project}") # /usr/[local]/share/<project>
+ set(INSTALL_CMAKE "share/${project}/cmake") # /usr/[local]/share/<project>
+ set(INSTALL_DATA "share/${project}") # /usr/[local]/share/<project>
+ set(INSTALL_BIN "bin") # /usr/[local]/bin
+ set(INSTALL_SHARED "lib") # /usr/[local]/lib
+ set(INSTALL_LIB "lib") # /usr/[local]/lib
+ set(INSTALL_INCLUDE "include") # /usr/[local]/include
+ set(INSTALL_DOC "share/doc/${project}") # /usr/[local]/share/doc/<project>
+ set(INSTALL_SHORTCUTS "share/applications") # /usr/[local]/share/applications
+ set(INSTALL_ICONS "share/pixmaps") # /usr/[local]/share/pixmaps
+ set(INSTALL_INIT "/etc/init") # /etc/init (upstart init scripts)
else()
- message(WARNING "Unsupported platform/compiler combination")
+ # Install into local directory
+ set(INSTALL_ROOT ".") # ./
+ set(INSTALL_CMAKE "cmake") # ./cmake
+ set(INSTALL_DATA ".") # ./bin
+ set(INSTALL_BIN ".") # ./bin
+ set(INSTALL_SHARED "lib") # ./lib
+ set(INSTALL_LIB "lib") # ./lib
+ set(INSTALL_INCLUDE "include") # ./include
+ set(INSTALL_DOC "doc") # ./doc
+ set(INSTALL_SHORTCUTS "misc") # ./misc
+ set(INSTALL_ICONS "misc") # ./misc
+ set(INSTALL_INIT "misc") # ./misc
endif()
-# Installation paths
-set(project ${META_PROJECT_NAME})
-if(WIN32)
-
- # "%PROGRAMFILES%/<project>/"
-
- set(INSTALL_ROOT ".")
- set(INSTALL_TOOLS "bin")
- set(INSTALL_EXAMPLES "bin")
- set(INSTALL_DATA "bin")
- set(INSTALL_BIN "bin")
- set(INSTALL_SHARED ".")
- set(INSTALL_LIB "lib")
- set(INSTALL_INCLUDE "include")
- set(INSTALL_DOC "doc")
- set(INSTALL_SHORTCUTS ".") # not available in windows
- set(INSTALL_ICONS ".") # not available in windows
- set(INSTALL_INIT ".") # not available in windows
-
-else()
-
- # "/user/[local]/"
-
- set(INSTALL_ROOT "share/${project}")
- set(INSTALL_TOOLS "share/${project}/tools")
- set(INSTALL_EXAMPLES "share/${project}/examples")
- set(INSTALL_DATA "share/${project}/examples")
- set(INSTALL_BIN "bin")
- set(INSTALL_SHARED "lib")
- set(INSTALL_LIB "lib")
- set(INSTALL_INCLUDE "include")
- set(INSTALL_DOC "share/doc/${project}")
- set(INSTALL_SHORTCUTS "share/applications")
- set(INSTALL_ICONS "share/pixmaps")
- set(INSTALL_INIT "/etc/init") # /etc/init (upstart init scripts)
-
- # Adjust target paths for portable installs
-
- # "<INSTALL_PREFIX>/"
-
- if(OPTION_PORTABLE_INSTALL)
- # Put binaries in root directory and keep data directory name
- set(INSTALL_ROOT ".")
- set(INSTALL_EXAMPLES ".")
- set(INSTALL_TOOLS ".")
- set(INSTALL_DATA ".")
- set(INSTALL_BIN ".")
-
- # We have to change the RPATH of binaries to achieve a usable local install.
- # [TODO] For binaries, "$ORIGIN/lib" is right, so that libraries are found in ./lib.
- # However, I have not yet tested what happens when libraries use other libraries.
- # In that case, they might need the rpath $ORIGIN instead ...
- set(CMAKE_SKIP_BUILD_RPATH FALSE) # Use automatic rpath for build
- set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) # Use specific rpath for INSTALL
- set(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE) # NO automatic rpath for INSTALL
-
- # Libraries are relative to binary
- if (APPLE)
- set(CMAKE_INSTALL_RPATH "@executable_path/${INSTALL_LIB}")
- else()
- set(CMAKE_INSTALL_RPATH "$ORIGIN/${INSTALL_LIB}")
- endif()
+# Set runtime path
+set(CMAKE_SKIP_BUILD_RPATH FALSE) # Add absolute path to all dependencies for BUILD
+set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) # Use CMAKE_INSTALL_RPATH for INSTALL
+set(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE) # Do NOT add path to dependencies for INSTALL
+
+if(NOT SYSTEM_DIR_INSTALL)
+ # Find libraries relative to binary
+ if(APPLE)
+ set(CMAKE_INSTALL_RPATH "@loader_path/../../../${INSTALL_LIB}")
else()
- if (APPLE)
- set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${INSTALL_LIB}") # Add rpath of project libraries
- set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) # Add rpaths of depending libraries
- endif()
+ set(CMAKE_INSTALL_RPATH "$ORIGIN/${INSTALL_LIB}")
endif()
endif()
-# Global deployment
+#
+# Project modules
+#
-# Add a revision file containing the git-head tag for cpack and install
-create_revision_file(${CMAKE_BINARY_DIR}/revision ${INSTALL_ROOT})
+add_subdirectory(source)
+add_subdirectory(codegeneration)
+add_subdirectory(docs)
+add_subdirectory(deploy)
-# Project meta files
-install(FILES ${CMAKE_BINARY_DIR}/revision DESTINATION ${INSTALL_ROOT} COMPONENT dev)
-if(NOT WIN32) # this leads to deployment of multiple revision files for unix package managers
- if(NOT OPTION_BUILD_STATIC)
- install(FILES ${CMAKE_BINARY_DIR}/revision DESTINATION ${INSTALL_ROOT} COMPONENT runtime)
- endif()
- install(FILES ${CMAKE_BINARY_DIR}/revision DESTINATION ${INSTALL_ROOT} COMPONENT examples)
- install(FILES ${CMAKE_BINARY_DIR}/revision DESTINATION ${INSTALL_ROOT} COMPONENT tools)
-endif()
+#
+# Deployment (global project files)
+#
-install(FILES AUTHORS DESTINATION ${INSTALL_ROOT} COMPONENT dev)
-install(FILES LICENSE DESTINATION ${INSTALL_ROOT} COMPONENT dev)
-install(FILES codegeneration/gl.revision DESTINATION ${INSTALL_ROOT} COMPONENT dev)
-install(FILES glbinding-config.cmake DESTINATION ${INSTALL_ROOT} COMPONENT dev)
+# Install version file
+install(FILES "${PROJECT_BINARY_DIR}/VERSION" DESTINATION ${INSTALL_ROOT} COMPONENT runtime)
-# Data files
-if(OPTION_BUILD_EXAMPLES)
- install(DIRECTORY ${CMAKE_SOURCE_DIR}/data DESTINATION ${INSTALL_DATA} COMPONENT examples)
-endif()
+# Install cmake find script for the project
+install(FILES ${META_PROJECT_NAME}-config.cmake DESTINATION ${INSTALL_ROOT} COMPONENT dev)
-# Include projects
+# Install the project meta files
+install(FILES AUTHORS DESTINATION ${INSTALL_ROOT} COMPONENT runtime)
+install(FILES LICENSE DESTINATION ${INSTALL_ROOT} COMPONENT runtime)
+install(FILES README.md DESTINATION ${INSTALL_ROOT} COMPONENT runtime)
-add_subdirectory(source)
-add_subdirectory(docs)
-add_subdirectory(packages)
-add_subdirectory(codegeneration)
+# Install runtime data
+install(DIRECTORY ${PROJECT_SOURCE_DIR}/data DESTINATION ${INSTALL_DATA} COMPONENT runtime)
View
@@ -1,5 +1,5 @@
-Copyright (c) 2014 Computer Graphics Systems Group at the Hasso-Plattner-Institute, Germany.
+Copyright (c) 2014-2015 Computer Graphics Systems Group at the Hasso-Plattner-Institute and CG Internals GmbH, Germany.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
Oops, something went wrong.

0 comments on commit f979fd3

Please sign in to comment.