| Gael Guennebaud | 20c11bc | 2008-12-02 12:59:10 +0000 | [diff] [blame] | 1 | project(Eigen) |
| Benoit Jacob | 24fd14d | 2009-01-12 16:14:13 +0000 | [diff] [blame] | 2 | set(EIGEN_VERSION_NUMBER "2.0-beta6") |
| Benoit Jacob | 252e0c4 | 2008-08-27 06:43:42 +0000 | [diff] [blame] | 3 | |
| 4 | #if the svnversion program is absent, this will leave the SVN_REVISION string empty, |
| 5 | #but won't stop CMake. |
| Gael Guennebaud | 20c11bc | 2008-12-02 12:59:10 +0000 | [diff] [blame] | 6 | execute_process(COMMAND svnversion -n ${CMAKE_SOURCE_DIR} |
| Benoit Jacob | 0e5c640 | 2009-01-04 17:32:20 +0000 | [diff] [blame] | 7 | OUTPUT_VARIABLE EIGEN_SVNVERSION_OUTPUT) |
| 8 | |
| 9 | #we only want EIGEN_SVN_REVISION if it is an actual revision number, not a string like "exported" |
| 10 | string(REGEX MATCH "^[0-9]+.*" EIGEN_SVN_REVISION "${EIGEN_SVNVERSION_OUTPUT}") |
| Benoit Jacob | 252e0c4 | 2008-08-27 06:43:42 +0000 | [diff] [blame] | 11 | |
| Gael Guennebaud | 20c11bc | 2008-12-02 12:59:10 +0000 | [diff] [blame] | 12 | if(EIGEN_SVN_REVISION) |
| 13 | set(EIGEN_VERSION "${EIGEN_VERSION_NUMBER} (SVN revision ${EIGEN_SVN_REVISION})") |
| 14 | else(EIGEN_SVN_REVISION) |
| 15 | set(EIGEN_VERSION "${EIGEN_VERSION_NUMBER}") |
| 16 | endif(EIGEN_SVN_REVISION) |
| Benoit Jacob | 252e0c4 | 2008-08-27 06:43:42 +0000 | [diff] [blame] | 17 | |
| Benoit Jacob | be64619 | 2009-01-04 16:19:12 +0000 | [diff] [blame] | 18 | cmake_minimum_required(VERSION 2.6.2) |
| Gael Guennebaud | 6416938 | 2008-05-31 23:21:49 +0000 | [diff] [blame] | 19 | |
| Gael Guennebaud | 2f6815d | 2008-08-23 17:40:52 +0000 | [diff] [blame] | 20 | set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) |
| Gael Guennebaud | da5e644 | 2008-08-23 17:25:54 +0000 | [diff] [blame] | 21 | |
| Gael Guennebaud | 20c11bc | 2008-12-02 12:59:10 +0000 | [diff] [blame] | 22 | option(EIGEN_BUILD_TESTS "Build tests" OFF) |
| 23 | option(EIGEN_BUILD_DEMOS "Build demos" OFF) |
| 24 | if(NOT WIN32) |
| 25 | option(EIGEN_BUILD_LIB "Build the binary shared library" OFF) |
| 26 | endif(NOT WIN32) |
| 27 | option(EIGEN_BUILD_BTL "Build benchmark suite" OFF) |
| Gael Guennebaud | 28539e7 | 2008-07-09 14:04:48 +0000 | [diff] [blame] | 28 | |
| Gael Guennebaud | 20c11bc | 2008-12-02 12:59:10 +0000 | [diff] [blame] | 29 | if(EIGEN_BUILD_LIB) |
| 30 | option(EIGEN_TEST_LIB "Build the unit tests using the library (disable -pedantic)" OFF) |
| 31 | endif(EIGEN_BUILD_LIB) |
| Benoit Jacob | 47b935f | 2007-05-30 06:57:40 +0000 | [diff] [blame] | 32 | |
| Gael Guennebaud | 20c11bc | 2008-12-02 12:59:10 +0000 | [diff] [blame] | 33 | set(CMAKE_INCLUDE_CURRENT_DIR ON) |
| Benoit Jacob | 47b935f | 2007-05-30 06:57:40 +0000 | [diff] [blame] | 34 | |
| Gael Guennebaud | 20c11bc | 2008-12-02 12:59:10 +0000 | [diff] [blame] | 35 | if(CMAKE_COMPILER_IS_GNUCXX) |
| 36 | if(CMAKE_SYSTEM_NAME MATCHES Linux) |
| Gael Guennebaud | 6e138d0 | 2008-12-17 18:37:04 +0000 | [diff] [blame] | 37 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wnon-virtual-dtor -Wno-long-long -ansi -Wundef -Wcast-align -Wchar-subscripts -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security -Wextra -fno-exceptions -fno-check-new -fno-common -fstrict-aliasing") |
| Gael Guennebaud | 20c11bc | 2008-12-02 12:59:10 +0000 | [diff] [blame] | 38 | if(NOT EIGEN_TEST_LIB) |
| 39 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic") |
| 40 | endif(NOT EIGEN_TEST_LIB) |
| Gael Guennebaud | 93f8d56 | 2008-12-18 09:07:36 +0000 | [diff] [blame] | 41 | |
| 42 | option(EIGEN_TEST_SSE2 "Enable/Disable SSE2 in tests/examples" OFF) |
| Gael Guennebaud | 20c11bc | 2008-12-02 12:59:10 +0000 | [diff] [blame] | 43 | if(EIGEN_TEST_SSE2) |
| 44 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse2") |
| 45 | message("Enabling SSE2 in tests/examples") |
| 46 | endif(EIGEN_TEST_SSE2) |
| Gael Guennebaud | 93f8d56 | 2008-12-18 09:07:36 +0000 | [diff] [blame] | 47 | |
| 48 | option(EIGEN_TEST_SSE3 "Enable/Disable SSE3 in tests/examples" OFF) |
| Gael Guennebaud | 20c11bc | 2008-12-02 12:59:10 +0000 | [diff] [blame] | 49 | if(EIGEN_TEST_SSE3) |
| 50 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse3") |
| 51 | message("Enabling SSE3 in tests/examples") |
| 52 | endif(EIGEN_TEST_SSE3) |
| Gael Guennebaud | 93f8d56 | 2008-12-18 09:07:36 +0000 | [diff] [blame] | 53 | |
| 54 | option(EIGEN_TEST_SSSE3 "Enable/Disable SSSE3 in tests/examples" OFF) |
| Gael Guennebaud | 20c11bc | 2008-12-02 12:59:10 +0000 | [diff] [blame] | 55 | if(EIGEN_TEST_SSSE3) |
| 56 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mssse3") |
| 57 | message("Enabling SSSE3 in tests/examples") |
| 58 | endif(EIGEN_TEST_SSSE3) |
| Gael Guennebaud | 93f8d56 | 2008-12-18 09:07:36 +0000 | [diff] [blame] | 59 | |
| 60 | option(EIGEN_TEST_ALTIVEC "Enable/Disable altivec in tests/examples" OFF) |
| Gael Guennebaud | 20c11bc | 2008-12-02 12:59:10 +0000 | [diff] [blame] | 61 | if(EIGEN_TEST_ALTIVEC) |
| 62 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -maltivec -mabi=altivec") |
| 63 | message("Enabling AltiVec in tests/examples") |
| 64 | endif(EIGEN_TEST_ALTIVEC) |
| Gael Guennebaud | 93f8d56 | 2008-12-18 09:07:36 +0000 | [diff] [blame] | 65 | |
| Gael Guennebaud | 20c11bc | 2008-12-02 12:59:10 +0000 | [diff] [blame] | 66 | endif(CMAKE_SYSTEM_NAME MATCHES Linux) |
| 67 | endif(CMAKE_COMPILER_IS_GNUCXX) |
| Benoit Jacob | 47b935f | 2007-05-30 06:57:40 +0000 | [diff] [blame] | 68 | |
| Gael Guennebaud | 93f8d56 | 2008-12-18 09:07:36 +0000 | [diff] [blame] | 69 | if(MSVC) |
| 70 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ") |
| 71 | |
| 72 | option(EIGEN_TEST_SSE2 "Enable/Disable SSE2 in tests/examples" OFF) |
| 73 | if(EIGEN_TEST_SSE2) |
| 74 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:SSE2") |
| 75 | message("Enabling SSE2 in tests/examples") |
| 76 | endif(EIGEN_TEST_SSE2) |
| 77 | endif(MSVC) |
| 78 | |
| Gael Guennebaud | c4c7066 | 2009-01-14 14:24:10 +0000 | [diff] [blame] | 79 | option(EIGEN_TEST_NO_EXPLICIT_VECTORIZATION "Disable explicit vectorization in tests/examples" OFF) |
| 80 | if(EIGEN_TEST_NO_EXPLICIT_VECTORIZATION) |
| Gael Guennebaud | 4f33fbf | 2009-01-15 08:26:40 +0000 | [diff] [blame] | 81 | add_definitions(-DEIGEN_DONT_VECTORIZE=1) |
| Gael Guennebaud | c4c7066 | 2009-01-14 14:24:10 +0000 | [diff] [blame] | 82 | message("Disabling vectorization in tests/examples") |
| 83 | endif(EIGEN_TEST_NO_EXPLICIT_VECTORIZATION) |
| 84 | |
| Gael Guennebaud | 20c11bc | 2008-12-02 12:59:10 +0000 | [diff] [blame] | 85 | include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) |
| Benoit Jacob | 47b935f | 2007-05-30 06:57:40 +0000 | [diff] [blame] | 86 | |
| Gael Guennebaud | 20c11bc | 2008-12-02 12:59:10 +0000 | [diff] [blame] | 87 | add_subdirectory(Eigen) |
| Gael Guennebaud | 28539e7 | 2008-07-09 14:04:48 +0000 | [diff] [blame] | 88 | |
| Gael Guennebaud | 20c11bc | 2008-12-02 12:59:10 +0000 | [diff] [blame] | 89 | if(EIGEN_BUILD_TESTS) |
| Gael Guennebaud | af27fb7 | 2009-01-08 11:53:21 +0000 | [diff] [blame] | 90 | include(CTest) |
| Gael Guennebaud | 20c11bc | 2008-12-02 12:59:10 +0000 | [diff] [blame] | 91 | add_subdirectory(test) |
| 92 | endif(EIGEN_BUILD_TESTS) |
| 93 | |
| 94 | add_subdirectory(doc) |
| 95 | |
| 96 | if(EIGEN_BUILD_DEMOS) |
| 97 | add_subdirectory(demos) |
| 98 | endif(EIGEN_BUILD_DEMOS) |
| 99 | |
| 100 | if(EIGEN_BUILD_BTL) |
| 101 | add_subdirectory(bench/btl) |
| 102 | endif(EIGEN_BUILD_BTL) |