2013-07-18 16:12:07 +00:00
|
|
|
cmake_minimum_required(VERSION 2.8.7)
|
|
|
|
project(LEAN CXX)
|
|
|
|
set(LEAN_VERSION_MAJOR 0)
|
|
|
|
set(LEAN_VERSION_MINOR 1)
|
2013-07-17 05:11:48 +00:00
|
|
|
|
2013-07-18 16:12:07 +00:00
|
|
|
set(CMAKE_COLOR_MAKEFILE ON)
|
|
|
|
enable_testing()
|
2013-07-17 05:11:48 +00:00
|
|
|
|
2013-09-20 19:31:06 +00:00
|
|
|
option(TRACK_MEMORY_USAGE "TRACK_MEMORY_USAGE" ON)
|
|
|
|
|
2013-09-04 04:55:40 +00:00
|
|
|
# Added for CTest
|
|
|
|
INCLUDE(CTest)
|
|
|
|
CONFIGURE_FILE(${LEAN_SOURCE_DIR}/CTestCustom.cmake.in
|
|
|
|
${LEAN_BINARY_DIR}/CTestCustom.cmake @ONLY)
|
|
|
|
|
2013-08-10 21:15:13 +00:00
|
|
|
set(LEAN_EXTRA_LINKER_FLAGS "")
|
2013-09-03 17:26:12 +00:00
|
|
|
set(LEAN_EXTRA_CXX_FLAGS "")
|
2013-08-10 21:15:13 +00:00
|
|
|
|
2013-08-23 00:46:18 +00:00
|
|
|
# Windows does not support ulimit -s unlimited. So, we reserve a lot of stack space: 100Mb
|
|
|
|
if((${CYGWIN} EQUAL "1") OR (${CMAKE_SYSTEM_NAME} MATCHES "Windows"))
|
|
|
|
message(STATUS "Windows detected")
|
2013-08-10 21:15:13 +00:00
|
|
|
set(LEAN_EXTRA_LINKER_FLAGS "${LEAN_EXTRA_LINKER_FLAGS} -Wl,--stack,104857600")
|
2013-09-03 17:26:12 +00:00
|
|
|
set(LEAN_EXTRA_CXX_FLAGS "${LEAN_EXTRA_CXX_FLAGS} -D LEAN_DEFAULT_PP_UNICODE=false")
|
2013-08-10 21:15:13 +00:00
|
|
|
endif()
|
|
|
|
|
2013-08-06 00:58:54 +00:00
|
|
|
# Set Module Path
|
|
|
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
|
|
|
|
|
2013-07-17 05:11:48 +00:00
|
|
|
# Initialize CXXFLAGS.
|
2013-09-20 05:52:52 +00:00
|
|
|
set(CMAKE_CXX_FLAGS "-Wall -Wextra -std=c++11 ${LEAN_EXTRA_CXX_FLAGS}")
|
2013-07-18 18:10:15 +00:00
|
|
|
set(CMAKE_CXX_FLAGS_DEBUG "-g -DLEAN_DEBUG -DLEAN_TRACE")
|
2013-07-17 05:11:48 +00:00
|
|
|
set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG")
|
|
|
|
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
|
|
|
|
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
|
2013-09-03 17:26:12 +00:00
|
|
|
set(CMAKE_CXX_FLAGS_TESTCOV "${CMAKE_CXX_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage")
|
2013-07-17 05:11:48 +00:00
|
|
|
|
|
|
|
# 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.8 OR GCC_VERSION VERSION_EQUAL 4.8))
|
|
|
|
message(FATAL_ERROR "${PROJECT_NAME} requires g++ 4.8 or greater.")
|
|
|
|
endif ()
|
|
|
|
elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
2013-08-13 07:29:18 +00:00
|
|
|
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
2013-08-12 17:32:07 +00:00
|
|
|
# In OSX, clang requires "-stdlib=libc++" to support C++11
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
|
|
|
|
set(LEAN_EXTRA_LINKER_FLAGS "-stdlib=libc++")
|
2013-08-13 07:29:18 +00:00
|
|
|
endif ()
|
2013-07-17 05:11:48 +00:00
|
|
|
else ()
|
|
|
|
message(FATAL_ERROR "Your C++ compiler does not support C++11.")
|
|
|
|
endif ()
|
|
|
|
|
2013-07-19 17:04:00 +00:00
|
|
|
# GMP
|
2013-08-06 02:33:33 +00:00
|
|
|
find_package(GMP 5.0.5)
|
2013-07-20 02:12:55 +00:00
|
|
|
set(EXTRA_LIBS ${EXTRA_LIBS} ${GMP_LIBRARIES})
|
2013-07-17 05:11:48 +00:00
|
|
|
|
2013-08-06 00:58:54 +00:00
|
|
|
# MPFR
|
2013-08-06 02:16:52 +00:00
|
|
|
find_package(MPFR 3.1.0)
|
2013-08-06 00:58:54 +00:00
|
|
|
set(EXTRA_LIBS ${EXTRA_LIBS} ${MPFR_LIBRARIES})
|
|
|
|
|
2013-09-20 19:31:06 +00:00
|
|
|
# TRACK_MEMORY_USAGE
|
|
|
|
if("${TRACK_MEMORY_USAGE}" MATCHES "ON")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D LEAN_TRACK_MEMORY")
|
|
|
|
endif()
|
|
|
|
|
2013-07-19 17:04:00 +00:00
|
|
|
# tcmalloc
|
2013-08-22 02:08:34 +00:00
|
|
|
option(TCMALLOC "TCMALLOC" ON)
|
|
|
|
if("${TCMALLOC}" MATCHES "ON")
|
2013-09-20 06:52:50 +00:00
|
|
|
find_package(Tcmalloc)
|
2013-07-20 21:19:36 +00:00
|
|
|
if(${TCMALLOC_FOUND})
|
|
|
|
set(EXTRA_LIBS ${EXTRA_LIBS} ${TCMALLOC_LIBRARIES})
|
2013-09-20 06:36:57 +00:00
|
|
|
message(STATUS "Using tcmalloc.")
|
2013-09-20 19:31:06 +00:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D HAS_TCMALLOC")
|
2013-09-20 06:36:57 +00:00
|
|
|
else()
|
|
|
|
message(WARNING "FAILED to find tcmalloc, using standard malloc.")
|
2013-07-20 21:19:36 +00:00
|
|
|
endif()
|
|
|
|
else()
|
2013-08-12 22:37:36 +00:00
|
|
|
message(STATUS "Using standard malloc.")
|
2013-07-18 22:10:31 +00:00
|
|
|
endif()
|
|
|
|
|
2013-08-22 02:08:34 +00:00
|
|
|
# Readline
|
|
|
|
option(READLINE "READLINE" OFF)
|
|
|
|
if("${READLINE}" MATCHES "ON")
|
|
|
|
find_package(Readline)
|
|
|
|
set(EXTRA_LIBS ${EXTRA_LIBS} ${READLINE_LIBRARY})
|
|
|
|
message(STATUS "Using GNU readline")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DLEAN_USE_READLINE")
|
|
|
|
endif()
|
|
|
|
|
2013-09-20 19:31:06 +00:00
|
|
|
# Check malloc_usable_size
|
|
|
|
if(NOT "${TCMALLOC_FOUND}" AND "${TRACK_MEMORY_USAGE}" MATCHES "ON")
|
|
|
|
find_package(MallocUsableSize)
|
2013-09-20 21:12:11 +00:00
|
|
|
if("${MUS_FOUND}" MATCHES "TRUE")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I ${MALLOC_DIR} -D HAS_MALLOC_USABLE_SIZE")
|
|
|
|
else()
|
2013-09-21 00:45:50 +00:00
|
|
|
find_package(MallocSize)
|
|
|
|
if("${MALLOCSIZE_FOUND}" MATCHES "TRUE")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I ${MALLOC_DIR} -D HAS_MALLOCSIZE")
|
|
|
|
else()
|
|
|
|
find_package(MSize)
|
|
|
|
if("${MSIZE_FOUND}" MATCHES "TRUE")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I ${MALLOC_DIR} -D HAS_MSIZE")
|
|
|
|
endif()
|
2013-09-20 21:12:11 +00:00
|
|
|
endif()
|
|
|
|
endif()
|
2013-09-20 19:31:06 +00:00
|
|
|
endif()
|
|
|
|
|
2013-09-13 03:04:10 +00:00
|
|
|
include_directories(${LEAN_SOURCE_DIR})
|
2013-07-19 17:04:00 +00:00
|
|
|
|
2013-07-17 05:10:18 +00:00
|
|
|
add_subdirectory(util)
|
2013-08-10 21:15:13 +00:00
|
|
|
set(LEAN_LIBS ${LEAN_LIBS} util)
|
2013-07-24 21:53:45 +00:00
|
|
|
add_subdirectory(util/numerics)
|
2013-08-10 21:15:13 +00:00
|
|
|
set(LEAN_LIBS ${LEAN_LIBS} numerics)
|
2013-08-13 10:40:51 +00:00
|
|
|
add_subdirectory(util/sexpr)
|
|
|
|
set(LEAN_LIBS ${LEAN_LIBS} sexpr)
|
2013-09-17 21:10:53 +00:00
|
|
|
add_subdirectory(util/interval)
|
2013-08-10 21:15:13 +00:00
|
|
|
set(LEAN_LIBS ${LEAN_LIBS} interval)
|
2013-07-22 11:03:46 +00:00
|
|
|
add_subdirectory(kernel)
|
2013-08-10 21:15:13 +00:00
|
|
|
set(LEAN_LIBS ${LEAN_LIBS} kernel)
|
2013-08-22 17:26:52 +00:00
|
|
|
add_subdirectory(library)
|
|
|
|
set(LEAN_LIBS ${LEAN_LIBS} library)
|
2013-09-07 06:17:24 +00:00
|
|
|
add_subdirectory(library/arith)
|
|
|
|
set(LEAN_LIBS ${LEAN_LIBS} arithlib)
|
2013-09-07 06:40:47 +00:00
|
|
|
add_subdirectory(library/cast)
|
|
|
|
set(LEAN_LIBS ${LEAN_LIBS} castlib)
|
2013-09-13 16:06:46 +00:00
|
|
|
add_subdirectory(library/all)
|
|
|
|
set(LEAN_LIBS ${LEAN_LIBS} alllib)
|
2013-08-21 16:04:49 +00:00
|
|
|
add_subdirectory(frontends/lean)
|
|
|
|
set(LEAN_LIBS ${LEAN_LIBS} lean_frontend)
|
2013-08-10 21:15:13 +00:00
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pthread ${LEAN_EXTRA_LINKER_FLAGS}")
|
2013-08-18 03:37:10 +00:00
|
|
|
set(CMAKE_EXE_LINKER_FLAGS_TESTCOV "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage")
|
2013-08-10 21:15:13 +00:00
|
|
|
set(EXTRA_LIBS ${LEAN_LIBS} ${EXTRA_LIBS})
|
2013-07-17 05:10:18 +00:00
|
|
|
add_subdirectory(shell)
|
2013-07-20 02:12:55 +00:00
|
|
|
add_subdirectory(tests/util)
|
2013-07-24 21:53:45 +00:00
|
|
|
add_subdirectory(tests/util/numerics)
|
2013-07-19 03:21:41 +00:00
|
|
|
add_subdirectory(tests/interval)
|
2013-07-22 11:03:46 +00:00
|
|
|
add_subdirectory(tests/kernel)
|
2013-08-23 16:35:35 +00:00
|
|
|
add_subdirectory(tests/library)
|
2013-08-21 16:04:49 +00:00
|
|
|
add_subdirectory(tests/frontends/lean)
|
2013-09-14 02:15:38 +00:00
|
|
|
|
|
|
|
# Include style check
|
|
|
|
include(StyleCheck)
|
|
|
|
file(GLOB_RECURSE LEAN_SOURCES
|
2013-09-14 03:00:55 +00:00
|
|
|
${LEAN_SOURCE_DIR}
|
2013-09-16 23:23:20 +00:00
|
|
|
${LEAN_SOURCE_DIR}/[A-Za-z]*.cpp
|
|
|
|
${LEAN_SOURCE_DIR}/[A-Za-z]*.h)
|
2013-09-14 02:15:38 +00:00
|
|
|
add_style_check_target(style "${LEAN_SOURCES}")
|
2013-09-14 03:00:55 +00:00
|
|
|
add_test(NAME style_check
|
|
|
|
COMMAND ${LEAN_SOURCE_DIR}/cmake/Modules/cpplint.py ${LEAN_SOURCES})
|