forked from microsoft/ELL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
122 lines (101 loc) · 4.04 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#
# cmake file for Embedded Learning Library subprojects
#
cmake_minimum_required(VERSION 3.3 FATAL_ERROR)
project(ELL)
# Define custom configuration types for Visual Studio
if(CMAKE_CONFIGURATION_TYPES)
# Copy important configuration info from Release config to new Documentation config
list(APPEND CMAKE_CONFIGURATION_TYPES Documentation)
set(CMAKE_CXX_FLAGS_DOCUMENTATION ${CMAKE_CXX_FLAGS_RELEASE})
set(CMAKE_C_FLAGS_DOCUMENTATION ${CMAKE_C_FLAGS_RELEASE})
set(CMAKE_EXE_LINKER_FLAGS_DOCUMENTATION ${CMAKE_EXE_LINKER_FLAGS_RELEASE})
set(CMAKE_EXE_LINKER_FLAGS_DOCUMENTATION ${CMAKE_EXE_LINKER_FLAGS_RELEASE})
set(CMAKE_SHARED_LINKER_FLAGS_DOCUMENTATION ${CMAKE_SHARED_LINKER_FLAGS_RELEASE})
set(CMAKE_MODULE_LINKER_FLAGS_DOCUMENTATION ${CMAKE_MODULE_LINKER_FLAGS_RELEASE})
endif()
# Options
# To set an option:
# cmake -DMyOption=ON|OFF buildDirectory
# (so if we're running cmake from a 'build' directory inside the main directory, do this:
# cmake -DBUILD_DOCS=OFF .. )
option(BUILD_DOC "Build Doxygen documentation" ON)
set(EXTERNAL_DIR "${CMAKE_SOURCE_DIR}/external" CACHE DOCUMENTATION "Directory to install external dependencies" )
# Include modules in the CMake directory.
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake")
# Turn on ability to create folders to organize projects
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# Set C++ version
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Apply -fPIC where applicable to the platform
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
if(MSVC)
# Set Visual Studio-specific options
add_definitions(-DUNICODE)
add_compile_options(/MP)
add_compile_options(/bigobj)
add_compile_options(/W4)
else()
# Set Clang/GCC-specific options
add_compile_options(-Wall)
add_compile_options(-Wno-missing-braces)
add_compile_options(-Wmissing-field-initializers)
add_compile_options(-fvisibility-inlines-hidden)
endif()
# Turn on ctest tests
enable_testing()
# Set up global variables to help find NuGet projects
set(PACKAGE_ROOT ${EXTERNAL_DIR})
include(OpenBLASSetup)
include(LLVMSetup)
include(SWIGSetup)
include(CopySharedLibraries)
include(AddPrecompiledHeader)
# Print helpful message if LLVM not found on Windows
if(NOT LLVM_FOUND AND WIN32)
message(WARNING "LLVM not found. Run the following command from the main project directory:\n nuget.exe restore external/packages.config -PackagesDirectory external")
endif()
# Include cmake projects for libraries and executables
add_subdirectory(libraries)
add_subdirectory(tools)
if(EXISTS ${CMAKE_SOURCE_DIR}/private AND EXISTS ${CMAKE_SOURCE_DIR}/private/CMakeLists.txt)
add_subdirectory(private)
endif()
# Add SWIG-generated interfaces
include(CommonInterfaces)
add_subdirectory(interfaces)
# Add examples (has dependencies on SWIG-generated interfaces)
add_subdirectory(examples)
# Add project for solution-level documentation
set (DOC README.md
StyleGuide.md)
add_custom_target(documentation ALL DEPENDS ${DOC} SOURCES ${DOC})
set_property(TARGET documentation PROPERTY FOLDER "documentation")
# Generate doxygen documentation
if(BUILD_DOC)
find_package(Doxygen 1.8 QUIET)
# search external NuGet package directory also
if(NOT DOXYGEN_FOUND)
set(DOXYGEN_PACKAGE_NAME Doxygen)
set(DOXYGEN_PACKAGE_VERSION 1.8.13)
set(DOXYGEN_PACKAGE_DIR ${PACKAGE_ROOT}/${DOXYGEN_PACKAGE_NAME}.${DOXYGEN_PACKAGE_VERSION})
find_program(DOXYGEN_EXECUTABLE doxygen
HINTS "${DOXYGEN_PACKAGE_DIR}/tools")
if(DOXYGEN_EXECUTABLE)
set(DOXYGEN_FOUND TRUE)
endif()
endif()
if(DOXYGEN_FOUND)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
set (DOXYFILE_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile")
add_custom_target(doc
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYFILE_LOCATION}
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
COMMENT "Building Doxygen documentation" VERBATIM
SOURCES Doxyfile)
set_property(TARGET doc PROPERTY FOLDER "documentation")
else()
message(WARNING "Doxygen processor not found")
endif()
endif()