-
Notifications
You must be signed in to change notification settings - Fork 7
/
CMakeLists.txt
121 lines (104 loc) · 4.4 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
cmake_minimum_required(VERSION 3.19)
string(REGEX REPLACE "(.*)/" "" THIS_FOLDER_NAME "${CMAKE_CURRENT_SOURCE_DIR}")
project(${THIS_FOLDER_NAME})
option(C74_BUILD_FAT "Build Universal Externals") # not supported (you're on your own! :-)
option(ENABLE_LTO "enable link-time / interprocedural optimization")
option(BUILD_THIRDPARTY_EXTERNALS "Enable building third-party externals")
option(BUILD_ZMQ_EXTERNALS "Enable building zeromq externals")
option(BUILD_MICROPYTHON_EXTERNAL "Enable building of micropython external")
option(FETCH_MICROPYTHON "Download latest micropython and use that to build external")
# use ccache if available
find_program(CCACHE_PROGRAM ccache)
if(CCACHE_PROGRAM)
message(STATUS "Found ccache in ${CCACHE_PROGRAM}")
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}")
endif()
if (ENABLE_LTO_IPO)
include(CheckIPOSupported)
check_ipo_supported(RESULT ipo_lto_supported OUTPUT check_lto_ipo_error)
if(ipo_lto_supported)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)
message(STATUS "IPO / LTO enabled")
else()
message(STATUS "IPO / LTO not supported: <${check_lto_ipo_error}>")
endif()
endif()
message(STATUS "CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}")
if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
if (${CMAKE_GENERATOR} MATCHES "Xcode")
if (${XCODE_VERSION} VERSION_LESS 10)
message(STATUS "Xcode 10 or higher is required. Please install from the Mac App Store.")
return ()
# elseif(${XCODE_VERSION} VERSION_GREATER_EQUAL 12)
# set(C74_BUILD_FAT YES)
endif ()
endif ()
if (NOT CMAKE_OSX_ARCHITECTURES)
if(C74_BUILD_FAT)
set(CMAKE_OSX_ARCHITECTURES "x86_64;arm64" CACHE STRING "macOS architecture" FORCE)
else()
set(CMAKE_OSX_ARCHITECTURES ${CMAKE_SYSTEM_PROCESSOR} CACHE STRING "macOS architecture" FORCE)
endif()
message("CMAKE_OSX_ARCHITECTURES set to ${CMAKE_OSX_ARCHITECTURES}")
endif()
# i.e check if homebrew is used, set local prefix accordingly
set(local_prefix "/usr/local")
execute_process(
COMMAND brew --prefix
OUTPUT_VARIABLE homebrew_prefix
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(DEFINED homebrew_prefix)
set(HAS_HOMEBREW 1)
set(local_prefix ${homebrew_prefix})
endif()
endif()
MACRO(SUBDIRLIST result curdir)
FILE(GLOB children RELATIVE ${curdir} ${curdir}/*)
SET(dirlist "")
FOREACH(child ${children})
IF(IS_DIRECTORY ${curdir}/${child})
LIST(APPEND dirlist ${child})
ENDIF()
ENDFOREACH()
SET(${result} ${dirlist})
ENDMACRO()
# Generate a project for every folder in the "source/category" folder
# SUBDIRLIST(CATEGORY_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/source)
# foreach (cat_dir ${CATEGORY_DIRS})
# SUBDIRLIST(PROJECT_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/source/${cat_dir})
# foreach (project_dir ${PROJECT_DIRS})
# set(project_path ${CMAKE_CURRENT_SOURCE_DIR}/source/${cat_dir}/${project_dir})
# #message("checking in: ${project_path}")
# if (EXISTS "${project_path}/CMakeLists.txt")
# message("Generating: ${project_dir}")
# add_subdirectory(${project_path})
# endif ()
# endforeach ()
# endforeach ()
# python3 externals
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/source/projects/cobra)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/source/projects/krait)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/source/projects/mamba)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/source/projects/mxpy)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/source/projects/py)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/source/projects/pyjs)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/source/projects/zedit)
# python variants
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/source/projects/pktpy)
if(BUILD_MICROPYTHON_EXTERNAL)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/source/projects/mpy)
endif()
# zmq externals
if(BUILD_ZMQ_EXTERNALS)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/source/projects/jmx)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/source/projects/zpy)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/source/projects/zthread)
endif()
# other externals
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/source/projects/cmx)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/source/projects/demo)
# thirdparty externals
if(BUILD_THIRDPARTY_EXTERNALS)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/source/projects/shell)
endif()