mirror of
https://github.com/GothenburgBitFactory/taskshell.git
synced 2025-06-26 10:54:29 +02:00
147 lines
5.4 KiB
CMake
147 lines
5.4 KiB
CMake
cmake_minimum_required (VERSION 2.8)
|
|
set(CMAKE_LEGACY_CYGWIN_WIN32 0) # Remove when CMake >= 2.8.4 is required
|
|
|
|
include (CheckFunctionExists)
|
|
include (CheckStructHasMember)
|
|
|
|
set (HAVE_CMAKE true)
|
|
|
|
project (tasksh)
|
|
set (PROJECT_VERSION "1.1.0")
|
|
|
|
message ("CMAKE_SYSTEM_NAME ${CMAKE_SYSTEM_NAME}")
|
|
|
|
include (CheckCXXCompilerFlag)
|
|
|
|
# NOTE: If we are to actually use C++11 features, we should either require
|
|
# a compiler that supports the -std=c++11 flag or check for the
|
|
# features used.
|
|
# Relying on -std=c++0x or even -std=gnu++0x is highly volatile.
|
|
|
|
CHECK_CXX_COMPILER_FLAG("-std=c++11" _HAS_CXX11)
|
|
CHECK_CXX_COMPILER_FLAG("-std=c++0x" _HAS_CXX0X)
|
|
CHECK_CXX_COMPILER_FLAG("-std=gnu++0x" _HAS_GNU0X)
|
|
|
|
if (_HAS_CXX11)
|
|
set (_CXX11_FLAGS "-std=c++11")
|
|
elseif (_HAS_CXX0X)
|
|
message (WARNING "Enabling -std=c++0x draft compile flag. Your compiler does not support the standard '-std=c++11' option. Consider upgrading.")
|
|
set (_CXX11_FLAGS "-std=c++0x")
|
|
elseif (_HAS_GNU0X)
|
|
message (WARNING "Enabling -std=gnu++0x draft compile flag. Your compiler does not support the standard '-std=c++11' option. Consider upgrading.")
|
|
set (_CXX11_FLAGS "-std=gnu++0x")
|
|
else (_HAS_CXX11)
|
|
message (FATAL_ERROR "C++11 support missing. Try upgrading your C++ compiler. If you have a good reason for using an outdated compiler, please let us know at support@taskwarrior.org.")
|
|
endif (_HAS_CXX11)
|
|
|
|
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
|
set (LINUX true)
|
|
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
|
set (DARWIN true)
|
|
set (_CXX11_FLAGS "${_CXX11_FLAGS} -stdlib=libc++")
|
|
elseif (${CMAKE_SYSTEM_NAME} MATCHES "kFreeBSD")
|
|
set (KFREEBSD true)
|
|
elseif (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
|
|
set (FREEBSD true)
|
|
elseif (${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
|
|
set (OPENBSD true)
|
|
elseif (${CMAKE_SYSTEM_NAME} MATCHES "NetBSD")
|
|
set (NETBSD true)
|
|
elseif (${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
|
|
set (SOLARIS true)
|
|
elseif (${CMAKE_SYSTEM_NAME} STREQUAL "GNU")
|
|
set (GNUHURD true)
|
|
elseif (${CMAKE_SYSTEM_NAME} STREQUAL "CYGWIN")
|
|
set (CYGWIN true)
|
|
# NOTE: Not setting -std=gnu++0x leads to compile errors even with
|
|
# GCC 4.8.3, and debugging those leads to insanity. Adding this
|
|
# workaround instead of fixing Cygwin.
|
|
set (_CXX11_FLAGS "-std=gnu++0x")
|
|
else (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
|
set (UNKNOWN true)
|
|
endif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
|
|
|
set (CMAKE_CXX_FLAGS "${_CXX11_FLAGS} ${CMAKE_CXX_FLAGS}")
|
|
|
|
set (CMAKE_CXX_FLAGS "-Wall -Wextra -Wsign-compare -Wreturn-type ${CMAKE_CXX_FLAGS}")
|
|
|
|
if (NETBSD)
|
|
# Since readline, etc likely to be in /usr/pkg/lib, not standard library
|
|
# Otherwise will remove links during install
|
|
set (CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
|
endif (NETBSD)
|
|
|
|
if (FREEBSD)
|
|
SET (TASKSH_MAN1DIR man/man1 CACHE STRING "Installation directory for man pages, section 1")
|
|
else (FREEBSD)
|
|
SET (TASKSH_MAN1DIR share/man/man1 CACHE STRING "Installation directory for man pages, section 1")
|
|
endif (FREEBSD)
|
|
SET (TASKSH_DOCDIR share/doc/tasksh CACHE STRING "Installation directory for doc files")
|
|
SET (TASKSH_RCDIR "${TASKSH_DOCDIR}/rc" CACHE STRING "Installation directory for configuration files")
|
|
SET (TASKSH_BINDIR bin CACHE STRING "Installation directory for the binary")
|
|
|
|
message ("-- Looking for SHA1 references")
|
|
if (EXISTS ${CMAKE_SOURCE_DIR}/.git/index)
|
|
set (HAVE_COMMIT true)
|
|
execute_process (COMMAND git log -1 --pretty=format:%h
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
|
OUTPUT_VARIABLE COMMIT)
|
|
configure_file ( ${CMAKE_SOURCE_DIR}/commit.h.in
|
|
${CMAKE_SOURCE_DIR}/commit.h)
|
|
message ("-- Found SHA1 reference: ${COMMIT}")
|
|
endif (EXISTS ${CMAKE_SOURCE_DIR}/.git/index)
|
|
|
|
set (PACKAGE "${PROJECT_NAME}")
|
|
set (VERSION "${PROJECT_VERSION}")
|
|
set (PACKAGE_BUGREPORT "support@taskwarrior.org")
|
|
set (PACKAGE_NAME "${PACKAGE}")
|
|
set (PACKAGE_TARNAME "${PACKAGE}")
|
|
set (PACKAGE_VERSION "${VERSION}")
|
|
set (PACKAGE_STRING "${PACKAGE} ${VERSION}")
|
|
|
|
# include the readline library finder module
|
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules")
|
|
|
|
# find readline
|
|
message ("-- Looking for GNU Readline")
|
|
find_package (Readline REQUIRED)
|
|
if (READLINE_FOUND)
|
|
set (HAVE_READLINE true)
|
|
set (TASKSH_INCLUDE_DIRS ${TASKSH_INCLUDE_DIRS} ${READLINE_INCLUDE_DIR})
|
|
set (TASKSH_LIBRARIES ${TASKSH_LIBRARIES} ${READLINE_LIBRARIES})
|
|
endif (READLINE_FOUND)
|
|
|
|
# Set the package language.
|
|
if (LANGUAGE)
|
|
set (PACKAGE_LANGUAGE ${LANGUAGE})
|
|
else (LANGUAGE)
|
|
set (PACKAGE_LANGUAGE 1)
|
|
endif (LANGUAGE)
|
|
|
|
set (LANGUAGE_ENG_USA 1)
|
|
|
|
message ("-- Configuring cmake.h")
|
|
configure_file (
|
|
${CMAKE_SOURCE_DIR}/cmake.h.in
|
|
${CMAKE_SOURCE_DIR}/cmake.h)
|
|
|
|
add_subdirectory (src)
|
|
add_subdirectory (doc)
|
|
if (EXISTS ${CMAKE_SOURCE_DIR}/test)
|
|
add_subdirectory (test EXCLUDE_FROM_ALL)
|
|
endif (EXISTS ${CMAKE_SOURCE_DIR}/test)
|
|
|
|
set (doc_FILES NEWS ChangeLog README.md INSTALL AUTHORS COPYING)
|
|
foreach (doc_FILE ${doc_FILES})
|
|
install (FILES ${doc_FILE} DESTINATION ${TASKSH_DOCDIR})
|
|
endforeach (doc_FILE)
|
|
|
|
# ---
|
|
|
|
set (CPACK_SOURCE_GENERATOR "TGZ")
|
|
set (CPACK_SOURCE_PACKAGE_FILE_NAME ${PACKAGE_NAME}-${PACKAGE_VERSION})
|
|
set (CPACK_SOURCE_IGNORE_FILES "CMakeCache" "CMakeFiles" "CPackConfig" "CPackSourceConfig"
|
|
"_CPack_Packages" "cmake_install" "install_manifest" "Makefile$"
|
|
"test" "package-config" "misc/*" "src/tasksh$"
|
|
"/\\\\.gitignore" "/\\\\.git/" "swp$")
|
|
include (CPack)
|