-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
143 lines (90 loc) · 3.91 KB
/
CMakeLists.txt
File metadata and controls
143 lines (90 loc) · 3.91 KB
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
### CMakeLists.txt
### platel top cmake file.
###
### See the file COPYING in the top directory for copyright and
### licensing information.
### Prologue
cmake_minimum_required(VERSION 3.30)
project(platel VERSION 0.42)
### Checking sytem/platform
message(STATUS "System is '${CMAKE_SYSTEM_NAME}'")
message(STATUS "UNIX is '${UNIX}'")
### Set the C standard.
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED True)
### Emacs setup.
find_program(EMACS NAMES emacs.exe emacs)
if(${EMACS} STREQUAL "EMACS-NOTFOUND")
message(FATAL_ERROR "Emacs cannot be found in default paths.")
endif()
message(STATUS "Emacs is '${EMACS}'")
set(EMACS_VERSION 29.2) # Minimum default.
# CMake 'execute_process' semantics requires "raw" strings passed to
# the command processor. Hence the two examples below don't work, but
# the code does.
# Three hours to figure this out!
#
# emacs -Q --batch [[--eval='(progn (princ emacs-version) emacs-version)']]
# emacs -Q --batch "--eval='(princ emacs-version)'"
execute_process(COMMAND ${EMACS} -Q --batch [[--eval=(princ emacs-version)]]
OUTPUT_VARIABLE EMACS_VERSION
COMMAND_ERROR_IS_FATAL ANY
)
message(STATUS "Emacs version is '${EMACS_VERSION}'")
if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin" AND
EXISTS "/Applications/Emacs.app/")
## We are on Mac OS and assume we are using the Emacs app, as
## installed by, e.g., homebrew from 'https://emacsformacosx.com/'
set(EMACS_MODULE_INCLUDE_DIR
"/Applications/Emacs.app/Contents/Resources/include/")
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Windows" AND
EXISTS "C:\\Program Files\\Emacs\\emacs-${EMACS_VERSION}\\include\\")
## We are on Windows with Emacs installed in a "standard" way.
set(EMACS_MODULE_INCLUDE_DIR
"C:\\Program Files\\Emacs\\emacs-${EMACS_VERSION}\\include\\")
elseif(${UNIX} AND
EXISTS "/usr/local/share/emacs/emacs-${EMACS_VERSION}/include/")
## We are on a UNI*X machine with Emacs installed in a "standard" way.
set(EMACS_MODULE_INCLUDE_DIR
"/usr/local/share/emacs/emacs-${EMACS_VERSION}/include/")
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin" OR
${CMAKE_SYSTEM_NAME} STREQUAL "Windows" OR
${UNIX})
message(FATAL_ERROR "Emacs include dir not found.")
else()
message(FATAL_ERROR "Unknown system '${CMAKE_SYSTEM_NAME}'.")
endif()
message(STATUS "Emacs include dir is '${EMACS_MODULE_INCLUDE_DIR}'")
### Global options.
### Ensure that the .dll is completely built if we are on Windows.
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS True)
option(BUILD_SHARED_LIBS "Build using shared libraries" ON)
message(STATUS "Building shared libraries: ${BUILD_SHARED_LIBS}")
### Declaring targets.
add_subdirectory(c)
add_library(platel_obj OBJECT c/platel.c)
add_executable(platel_test c/platel_test.c $<TARGET_OBJECTS:platel_obj>)
### Declaring shared libraries destinations.
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}")
target_link_libraries(platel_test PUBLIC platel_obj)
target_include_directories(platel_test PUBLIC "${PROJECT_BINARY_DIR}")
### Installation instructions.
### Installing in the top directory, i.e., PROJECT_SOURCE_DIR.
install(TARGETS platel_test
DESTINATION ${PROJECT_SOURCE_DIR}
CONFIGURATIONS Debug
)
### Epilogue.
message(STATUS "Epilogue...")
message(STATUS "CMAKE_BINARY_DIR = ${CMAKE_BINARY_DIR}")
message(STATUS "CMAKE_SOURCE_DIR = ${CMAKE_SOURCE_DIR}")
message(STATUS "PROJECT_BINARY_DIR = ${PROJECT_BINARY_DIR}")
message(STATUS "PROJECT_SOURCE_DIR/c = ${PROJECT_SOURCE_DIR}/c")
message(STATUS "EMACS_MODULE_INCLUDE_DIR = ${EMACS_MODULE_INCLUDE_DIR}")
message(STATUS "CMAKE_INSTALL_PREFIX = ${CMAKE_INSTALL_PREFIX}")
message(STATUS "CMAKE_INCLUDE_PATH = ${CMAKE_INCLUDE_PATH}")
message(STATUS "CMAKE_LIBRARY_PATH = ${CMAKE_LIBRARY_PATH}")
message(STATUS "CMAKE_PREFIX_PATH = ${CMAKE_PREFIX_PATH}")
### CMakeLists.txt ends here.