CMakeLists.txt 1.93 KB
Newer Older
Pascal Palenda's avatar
Pascal Palenda committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
set (CPM_DOWNLOAD_VERSION 0.32.2)
set (CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")

if (NOT (EXISTS ${CPM_DOWNLOAD_LOCATION}))
	message (STATUS "Downloading CPM.cmake")
	file (DOWNLOAD https://github.com/TheLartians/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake
		  ${CPM_DOWNLOAD_LOCATION}
	)
else (NOT (EXISTS ${CPM_DOWNLOAD_LOCATION}))
	message ("CPM already exists, do not need to download")
endif (NOT (EXISTS ${CPM_DOWNLOAD_LOCATION}))

include (${CPM_DOWNLOAD_LOCATION})

Pascal Palenda's avatar
Pascal Palenda committed
15
16
17
18
if (TBB_DIR)
	unset (TBB_DIR CACHE)
endif ()

Pascal Palenda's avatar
Pascal Palenda committed
19
20
21
22
CPMAddPackage (
	NAME tbb
	GITHUB_REPOSITORY oneapi-src/oneTBB
	GIT_TAG v2021.3.0
Pascal Palenda's avatar
Pascal Palenda committed
23
	OPTIONS "TBB_TEST OFF" "TBBMALLOC_BUILD OFF" "TBB_FIND_PACKAGE OFF"
Pascal Palenda's avatar
Pascal Palenda committed
24
25
26
27
28
)

if (tbb_ADDED)
	set_target_properties (tbb tbbmalloc tbbmalloc_proxy PROPERTIES FOLDER "external_libs")

Pascal Palenda's avatar
Pascal Palenda committed
29
	# TBB sets all output directories for debug/release so we must overwrite them
Pascal Palenda's avatar
Pascal Palenda committed
30
	if (WIN32)
31
		if (CMAKE_PDB_OUTPUT_DIRECTORY)
Pascal Palenda's avatar
Pascal Palenda committed
32
33
34
35
			set (_pdb_dir ${CMAKE_PDB_OUTPUT_DIRECTORY})
		else ()
			set (_pdb_dir ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
		endif ()
Pascal Palenda's avatar
Pascal Palenda committed
36
		set_target_properties (
Pascal Palenda's avatar
Pascal Palenda committed
37
38
39
40
41
42
43
44
45
46
47
48
49
			tbb tbbmalloc tbbmalloc_proxy
			PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
					   RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
					   RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
					   ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}
					   ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}
					   ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}
					   LIBRARY_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
					   LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
					   LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
					   PDB_OUTPUT_DIRECTORY ${_pdb_dir}
					   PDB_OUTPUT_DIRECTORY_DEBUG ${_pdb_dir}
					   PDB_OUTPUT_DIRECTORY_RELEASE ${_pdb_dir}
Pascal Palenda's avatar
Pascal Palenda committed
50
		)
Pascal Palenda's avatar
Pascal Palenda committed
51
		unset (_pdb_dir)
Pascal Palenda's avatar
Pascal Palenda committed
52
53
	endif ()
endif ()