CMakeLists.txt 2.69 KB
Newer Older
edwin's avatar
edwin committed
1
2
3
cmake_minimum_required(VERSION 2.8)
project(MILENA)

edwin.carlinet's avatar
edwin.carlinet committed
4
5
6
# Add FindTBB directory to CMake's module path
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/")

Michaël Roynard's avatar
Cleanup    
Michaël Roynard committed
7
find_package(Boost 1.42 COMPONENTS program_options REQUIRED)
Edwin Carlinet's avatar
Edwin Carlinet committed
8
find_package(FreeImage REQUIRED)
edwin.carlinet's avatar
edwin.carlinet committed
9
find_package(TBB)
Edwin Carlinet's avatar
Edwin Carlinet committed
10
find_package(Qt4)
edwin.carlinet's avatar
edwin.carlinet committed
11

12
13
14
# CONFIGURATION OPTIONS
set(MLN_USE_TBB YES CACHE BOOL "Set to NO to disable use of TBB and parallelization")

15
16
17
18
19
20
21
22
# Proper project creation
set(MLN_INCLUDE_DIR "${PROJECT_SOURCE_DIR}")
if(MSVC OR APPLE)
  #dummy static project not linked anywere needed so that a vcxproj is generated with the sources in the solution
  set_property(GLOBAL PROPERTY USE_FOLDERS ON)
  file(GLOB_RECURSE MLN_SOURCES  "${MLN_INCLUDE_DIR}/*.hpp")
  add_library(Mln_srcs STATIC ${MLN_SOURCES})
  set_target_properties(Mln_srcs PROPERTIES LINKER_LANGUAGE CXX)
23
  # target_compile_features(Mln_srcs PUBLIC cxx_std_14)
24
25
26
27
28
  target_include_directories(Mln_srcs PUBLIC ${MLN_INCLUDE_DIR})
  source_group(TREE ${MLN_INCLUDE_DIR} FILES ${MLN_SOURCES})
endif()

add_library(Mln INTERFACE)
29
# target_compile_features(Mln INTERFACE cxx_std_14)
30
target_include_directories(Mln INTERFACE ${MLN_INCLUDE_DIR})
edwin's avatar
edwin committed
31

32
include_directories(SYSTEM ${Boost_INCLUDE_DIR})
ecarlinet's avatar
ecarlinet committed
33
34
include_directories(${FreeImage_INCLUDE_DIRS})
link_directories(${FreeImage_LIBRARY_DIR})
35
link_directories(${Boost_LIBRARY_DIRS})
36
37
38
39
40
41

if (TBB_FOUND AND MLN_USE_TBB)
  include_directories(${TBB_INCLUDE_DIRS})
  link_directories(${TBB_LIBRARY_DIRS})
  link_libraries(${TBB_LIBRARIES})
else()
42
  set(MLN_USE_TBB OFF)
43
44
  add_definitions(-DMLN_NO_TBB)
endif()
edwin's avatar
edwin committed
45

46
47
48
49
if (UNIX AND NOT APPLE)
   link_libraries(rt)
endif()

ecarlinet's avatar
ecarlinet committed
50

51
if ((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") OR (CMAKE_CXX_COMPILER_ID STREQUAL "GNU"))
Edwin Carlinet's avatar
Edwin Carlinet committed
52
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -W -Wextra -Wall -std=c++14 -Werror")
Edwin Carlinet's avatar
Edwin Carlinet committed
53
  set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
54
elseif (MSVC)
55
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX /W4 /wd4244 /wd4127 /permissive- /std:c++14" )
Edwin Carlinet's avatar
Edwin Carlinet committed
56
  add_definitions(-D_SCL_SECURE_NO_WARNINGS)
57
endif()
58

Edwin Carlinet's avatar
Edwin Carlinet committed
59

60
61
62
63
64
# default buidling type
if (NOT CMAKE_BUILD_TYPE)
  message(STATUS "No build type selected, default to Release")
  set(CMAKE_BUILD_TYPE "Release")
endif()
edwin's avatar
edwin committed
65
66


67
# Testing
edwin's avatar
edwin committed
68
ENABLE_TESTING()
69

Edwin Carlinet's avatar
Edwin Carlinet committed
70
71
72
#### Configuration of the Compiler ###
# set BOOST to use variadic macros
add_definitions(-D BOOST_PP_VARIADICS=1)
73
74
75
76



# Subdirectories
Edwin Carlinet's avatar
Edwin Carlinet committed
77
add_subdirectory(doc EXCLUDE_FROM_ALL)
78
79
80
add_subdirectory(tests EXCLUDE_FROM_ALL)
add_subdirectory(bench EXCLUDE_FROM_ALL)
add_subdirectory(apps EXCLUDE_FROM_ALL)
Edwin Carlinet's avatar
Edwin Carlinet committed
81
add_subdirectory(cli EXCLUDE_FROM_ALL)
edwin's avatar
edwin committed
82

edwin.carlinet's avatar
edwin.carlinet committed
83
84
set(CPACK_SOURCE_GENERATOR "TBZ2")
set(CPACK_SOURCE_IGNORE_FILES "${CMAKE_CURRENT_BINARY_DIR}/;/\\\\.git/;.*~;#.*#")
edwin's avatar
edwin committed
85
INCLUDE(CPack)
edwin.carlinet's avatar
edwin.carlinet committed
86
add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source)