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-10-25 18:50:35 +00:00
|
|
|
option(THREAD_SAFE "THREAD_SAFE" ON)
|
2013-09-20 19:31:06 +00:00
|
|
|
|
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-11-18 17:52:47 +00:00
|
|
|
set(LEAN_EXTRA_CXX_FLAGS "${LEAN_EXTRA_CXX_FLAGS} -D LEAN_WINDOWS")
|
|
|
|
endif()
|
|
|
|
|
2013-10-25 18:50:35 +00:00
|
|
|
if("${THREAD_SAFE}" MATCHES "OFF")
|
|
|
|
message(STATUS "Disabled thread-safety, it will not be safe to run multiple threads in parallel")
|
|
|
|
set(LEAN_EXTRA_CXX_FLAGS "${LEAN_EXTRA_CXX_FLAGS} -D LEAN_THREAD_UNSAFE")
|
|
|
|
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-27 03:22:40 +00:00
|
|
|
|
|
|
|
# Test coverage
|
|
|
|
if("${TESTCOV}" MATCHES "ON")
|
2013-09-27 05:24:24 +00:00
|
|
|
include(CodeCoverage)
|
2013-09-27 03:22:40 +00:00
|
|
|
message(STATUS "Enable test-coverage")
|
2013-09-27 17:23:52 +00:00
|
|
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -fprofile-arcs -ftest-coverage --coverage")
|
2013-09-27 05:24:24 +00:00
|
|
|
setup_target_for_coverage(cov ${LEAN_SOURCE_DIR}/../script/run_tests.sh coverage)
|
2013-09-27 03:22:40 +00:00
|
|
|
endif()
|
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-08-06 00:58:54 +00:00
|
|
|
# MPFR
|
2013-08-06 02:16:52 +00:00
|
|
|
find_package(MPFR 3.1.0)
|
2013-10-26 03:35:06 +00:00
|
|
|
include_directories(${MPFR_INCLUDES})
|
2013-08-06 00:58:54 +00:00
|
|
|
set(EXTRA_LIBS ${EXTRA_LIBS} ${MPFR_LIBRARIES})
|
|
|
|
|
2013-11-06 00:30:36 +00:00
|
|
|
# GMP
|
|
|
|
find_package(GMP 5.0.5)
|
|
|
|
include_directories(${GMP_INCLUDE_DIR})
|
|
|
|
set(EXTRA_LIBS ${EXTRA_LIBS} ${GMP_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-11-08 18:56:29 +00:00
|
|
|
find_package(Lua REQUIRED)
|
|
|
|
set(EXTRA_LIBS ${EXTRA_LIBS} ${LUA_LIBRARIES})
|
2013-11-14 02:44:01 +00:00
|
|
|
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
|
|
|
# Lua static library for linux depends on dl.so
|
|
|
|
set(EXTRA_LIBS ${EXTRA_LIBS} -ldl)
|
|
|
|
endif()
|
2013-11-08 18:56:29 +00:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I ${LUA_INCLUDE_DIR}")
|
|
|
|
if ("${HAS_LUA_NEWSTATE}$" MATCHES "TRUE")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D LEAN_USE_LUA_NEWSTATE")
|
|
|
|
endif()
|
2013-11-02 18:16:30 +00:00
|
|
|
|
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-09-25 22:38:16 +00:00
|
|
|
add_subdirectory(library/rewriter)
|
|
|
|
set(LEAN_LIBS ${LEAN_LIBS} rewriter)
|
2013-10-03 22:02:07 +00:00
|
|
|
add_subdirectory(library/elaborator)
|
|
|
|
set(LEAN_LIBS ${LEAN_LIBS} elaborator)
|
2013-11-07 21:56:04 +00:00
|
|
|
add_subdirectory(frontends/lean)
|
|
|
|
set(LEAN_LIBS ${LEAN_LIBS} lean_frontend)
|
2013-11-15 20:13:03 +00:00
|
|
|
add_subdirectory(bindings/lua)
|
|
|
|
set(LEAN_LIBS ${LEAN_LIBS} lua)
|
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-10-22 01:17:34 +00:00
|
|
|
add_subdirectory(tests/util/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-09-25 22:38:16 +00:00
|
|
|
add_subdirectory(tests/library/rewriter)
|
2013-10-14 15:16:23 +00:00
|
|
|
add_subdirectory(tests/library/elaborator)
|
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-27 05:24:24 +00:00
|
|
|
add_test(NAME style_check COMMAND ${LEAN_SOURCE_DIR}/cmake/Modules/cpplint.py ${LEAN_SOURCES})
|