mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
Build: Migrated to external common lib
This commit is contained in:
parent
df6ef30fe3
commit
77f51a41bd
4 changed files with 75 additions and 88 deletions
|
@ -1,81 +1,14 @@
|
|||
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 (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
|
||||
set (HAVE_CMAKE true)
|
||||
|
||||
project (timew)
|
||||
include (CXXSniffer)
|
||||
include (ExternalProject)
|
||||
|
||||
set (PROJECT_VERSION "1.0.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 (FREEBSD)
|
||||
SET (TIMEW_MAN1DIR man/man1 CACHE STRING "Installation directory for man pages, section 1")
|
||||
SET (TIMEW_MAN5DIR man/man5 CACHE STRING "Installation directory for man pages, section 5")
|
||||
else (FREEBSD)
|
||||
SET (TIMEW_MAN1DIR share/man/man1 CACHE STRING "Installation directory for man pages, section 1")
|
||||
SET (TIMEW_MAN5DIR share/man/man5 CACHE STRING "Installation directory for man pages, section 5")
|
||||
endif (FREEBSD)
|
||||
SET (TIMEW_DOCDIR share/doc/timew CACHE STRING "Installation directory for doc files")
|
||||
SET (TIMEW_RCDIR "${TIMEW_DOCDIR}/rc" CACHE STRING "Installation directory for configuration files")
|
||||
SET (TIMEW_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)
|
||||
|
@ -100,8 +33,13 @@ configure_file (
|
|||
${CMAKE_SOURCE_DIR}/cmake.h.in
|
||||
${CMAKE_SOURCE_DIR}/cmake.h)
|
||||
|
||||
ExternalProject_Add (common-1.0
|
||||
GIT_REPOSITORY "ssh://git@git.tasktools.org/tm/common.git"
|
||||
GIT_TAG "master"
|
||||
# UPDATE_DISCONNECTED 1 # Needs 3.2
|
||||
)
|
||||
|
||||
add_subdirectory (src)
|
||||
add_subdirectory (src/common)
|
||||
if (EXISTS ${CMAKE_SOURCE_DIR}/test)
|
||||
add_subdirectory (test EXCLUDE_FROM_ALL)
|
||||
endif (EXISTS ${CMAKE_SOURCE_DIR}/test)
|
||||
|
@ -117,7 +55,6 @@ 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/timew$" "src/common/libcommon.a"
|
||||
"performance" "src/libtimew.a" "/\\\\.gitignore" "/\\\\.git/" "swp$"
|
||||
"src/gr$")
|
||||
"test" "package-config" "src/timew$" "src/libtimew.a"
|
||||
"/\\\\.gitignore" "/\\\\.git/" "swp$" "src/gr$")
|
||||
include (CPack)
|
||||
|
|
51
cmake/CXXSniffer.cmake
Normal file
51
cmake/CXXSniffer.cmake
Normal file
|
@ -0,0 +1,51 @@
|
|||
message ("-- Configuring C++11")
|
||||
message ("-- System: ${CMAKE_SYSTEM_NAME}")
|
||||
|
||||
include (CheckCXXCompilerFlag)
|
||||
|
||||
# NOTE: Phase out -std=gnu++0x and --std=c++0x as soon as realistically possible.
|
||||
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}")
|
|
@ -1,7 +1,6 @@
|
|||
cmake_minimum_required (VERSION 2.8)
|
||||
include_directories (${CMAKE_SOURCE_DIR}
|
||||
${CMAKE_SOURCE_DIR}/src
|
||||
${CMAKE_SOURCE_DIR}/src/common
|
||||
${TIMEW_INCLUDE_DIRS})
|
||||
|
||||
set (timew_SRCS Grammar.cpp Grammar.h
|
||||
|
@ -11,14 +10,16 @@ set (timew_SRCS Grammar.cpp Grammar.h
|
|||
Rules.cpp Rules.h)
|
||||
|
||||
add_library (timew STATIC ${timew_SRCS})
|
||||
include_directories(${CMAKE_INSTALL_PREFIX}/include)
|
||||
link_directories(${CMAKE_INSTALL_PREFIX}/lib)
|
||||
add_executable (timew_executable timew.cpp)
|
||||
add_executable (gr_executable gr.cpp)
|
||||
|
||||
target_link_libraries (timew_executable common timew ${TIMEW_LIBRARIES})
|
||||
target_link_libraries (gr_executable common timew ${TIMEW_LIBRARIES})
|
||||
target_link_libraries (timew_executable timew common ${TIMEW_LIBRARIES})
|
||||
target_link_libraries (gr_executable timew common ${TIMEW_LIBRARIES})
|
||||
|
||||
set_property (TARGET timew_executable PROPERTY OUTPUT_NAME "timew")
|
||||
set_property (TARGET gr_executable PROPERTY OUTPUT_NAME "gr")
|
||||
|
||||
install (TARGETS timew_executable DESTINATION ${TIMEW_BINDIR})
|
||||
install (TARGETS timew_executable DESTINATION bin)
|
||||
|
||||
|
|
|
@ -5,19 +5,17 @@ endif()
|
|||
|
||||
include_directories (${CMAKE_SOURCE_DIR}
|
||||
${CMAKE_SOURCE_DIR}/src
|
||||
${CMAKE_SOURCE_DIR}/src/common
|
||||
${CMAKE_SOURCE_DIR}/test
|
||||
${TIMEW_INCLUDE_DIRS})
|
||||
${CMAKE_SOURCE_DIR}/test)
|
||||
|
||||
set (test_SRCS color.t fs.t grammar.t lexer.t list.t lr0.t pig.t rules.t rx.t table.t text.t unicode.t utf8.t)
|
||||
include_directories (${CMAKE_INSTALL_PREFIX}/include)
|
||||
link_directories(${CMAKE_INSTALL_PREFIX}/lib)
|
||||
|
||||
set (test_SRCS grammar.t lexer.t lr0.t pig.t rules.t)
|
||||
|
||||
add_custom_target (test ./run_all --verbose
|
||||
DEPENDS ${test_SRCS} timew_executable
|
||||
DEPENDS ${test_SRCS}
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/test)
|
||||
|
||||
add_custom_target (build_tests DEPENDS ${test_SRCS}
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/test)
|
||||
|
||||
foreach (src_FILE ${test_SRCS})
|
||||
add_executable (${src_FILE} "${src_FILE}.cpp" test.cpp)
|
||||
target_link_libraries (${src_FILE} timew common ${TIMEW_LIBRARIES})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue