-
Notifications
You must be signed in to change notification settings - Fork 12
/
CMakeLists.txt
83 lines (64 loc) · 2.8 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
cmake_minimum_required(VERSION 2.8.4 FATAL_ERROR)
set(PROJECT_NAME wdenoise)
project(${PROJECT_NAME} CXX C)
# src root path
set(WDENOISE_SRC_ROOT ${PROJECT_SOURCE_DIR} CACHE PATH "wdenoise source root")
# Global settings
set(GLOBAL_OUTPUT_PATH ${PROJECT_BINARY_DIR}/Bin)
set(CMAKE_INSTALL_PREFIX ${PROJECT_BINARY_DIR}/install)
# Sets global output directory for single configuration (GCC)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${GLOBAL_OUTPUT_PATH})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${GLOBAL_OUTPUT_PATH})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${GLOBAL_OUTPUT_PATH})
# Sets global output directory for sub-configurations (msvc, mingw)
foreach(OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES})
string(TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${GLOBAL_OUTPUT_PATH})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${GLOBAL_OUTPUT_PATH})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${GLOBAL_OUTPUT_PATH})
endforeach(OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES)
# make include globaly visible
set(PROJECT_WIDE_INCLUDE ${WDENOISE_SRC_ROOT}/header)
include_directories(${PROJECT_WIDE_INCLUDE})
if(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS -std=c++11)
else()
add_definitions(-DWIN32) # TMP
endif()
option(BUILD_UT "Enable Unit test" ON)
find_package(Git QUIET)
if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
# Update submodules as needed
option(GIT_SUBMODULE "Check submodules during build" ON)
if(GIT_SUBMODULE)
message(STATUS "Submodule update")
execute_process(COMMAND git submodule update --init --recursive wavelib
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
RESULT_VARIABLE GIT_SUBMOD_RESULT)
if(NOT GIT_SUBMOD_RESULT EQUAL "0")
message(FATAL_ERROR "git submodule update --init failed with ${GIT_SUBMOD_RESULT}, please checkout submodules")
endif()
endif()
endif()
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/wavelib/CMakeLists.txt")
message(FATAL_ERROR "The submodules were not downloaded! GIT_SUBMODULE was turned off or failed. Please update submodules and try again.")
endif()
add_subdirectory(wavelib)
# Global link directories
link_directories(${GLOBAL_OUTPUT_PATH})
# Copies files from build directory into install directory.
file(COPY ${WDENOISE_SRC_ROOT}/wavelib/header/wavelib.h DESTINATION ${WDENOISE_SRC_ROOT}/header)
# Remove executables and libraries that are not needed
file(GLOB_RECURSE MY_FILES
${GLOBAL_OUTPUT_PATH}/libwauxlib.a
${GLOBAL_OUTPUT_PATH}/wavelibLibTests.exe
${CMAKE_SOURCE_DIR}/test
)
#file(REMOVE ${MY_FILES})
if(BUILD_UT)
include(CTest)
enable_testing()
add_subdirectory(unitTests)
endif()
add_subdirectory(src)
add_subdirectory(examples)