-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathCMakeLists.txt
59 lines (47 loc) · 2.33 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
cmake_minimum_required(VERSION 2.6)
# set default build type to Release
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
endif(NOT CMAKE_BUILD_TYPE)
# Force out of source build. Otherwise multiple platform builds will not work.
# http://stackoverflow.com/questions/11143062/getting-cmake-to-build-out-of-source-without-wrapping-scripts
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
if (${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
project(stub NONE)
set(OUT_OF_SOURCE_DIR "build-${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}-${CMAKE_BUILD_TYPE}")
message(WARNING "In-source builds not allowed. CMake will now be run with arguments: cmake -H. -B${OUT_OF_SOURCE_DIR}")
# Run CMake with out of source flag
execute_process(
COMMAND ${CMAKE_COMMAND} -H. -B${OUT_OF_SOURCE_DIR} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
RESULT_VARIABLE rc)
if (rc)
message(FATAL_ERROR "cmake failed to configure out of source build.")
endif()
if (MAKE_IMMEDIATELY)
execute_process(
COMMAND make ${MAKE_IMMEDIATELY}
WORKING_DIRECTORY ${OUT_OF_SOURCE_DIR}
RESULT_VARIABLE rc)
if (rc)
message(FATAL_ERROR "Target ${MAKE_IMMEDIATELY} failed.")
endif()
endif()
# Cause fatal error to stop the script from further execution
# It would be more pretty if we could return a zero result here but everything else seems not to prevent a meaningless Makefile to be generated.
message(FATAL_ERROR "CMake has been ran to create an out of source build => abort. This is NOT an error!")
endif ()
project(vc4asm)
# Place results in the top level
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
add_subdirectory(src)
# install TARGETS links the executables a second time, taking twice a much time just for nothing.
# install(TARGETS vc4asm vc4dis RUNTIME DESTINATION bin)
# work around: use install PROGRAMS
install(PROGRAMS $<TARGET_FILE:vc4asm> $<TARGET_FILE:vc4dis> DESTINATION bin)
install(PROGRAMS $<TARGET_FILE:libvc4asm-static> $<TARGET_FILE:libvc4asm-shared> DESTINATION lib)
install(DIRECTORY share/vc4inc share/vc4tmpl DESTINATION share)
enable_testing()
add_subdirectory(test EXCLUDE_FROM_ALL)