-
Notifications
You must be signed in to change notification settings - Fork 30
/
CMakeLists.txt
655 lines (560 loc) · 22.5 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
# -*- mode:cmake -*-
# Copyright 2021-2022 The Foedag team
# GPL License
# Copyright (c) 2021-2022 The Open-Source FPGA Foundation
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
cmake_minimum_required(VERSION 3.15)
# Detect build type, fallback to release and throw a warning if use didn't
# specify any
if(NOT CMAKE_BUILD_TYPE)
message(WARNING "Build type not set, falling back to Release mode.
To specify build type use:
-DCMAKE_BUILD_TYPE=<mode> where <mode> is Debug or Release.")
set(CMAKE_BUILD_TYPE
"Release"
CACHE STRING "Choose the type of build, options are: Debug Release."
FORCE)
endif(NOT CMAKE_BUILD_TYPE)
set(VERSION_MAJOR 0)
set(VERSION_MINOR 0)
# Add the spdlog directory to the include path
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/third_party/spdlog/include ${CMAKE_CURRENT_SOURCE_DIR}/third_party/exprtk ${CMAKE_CURRENT_SOURCE_DIR}/third_party/scope_guard)
set(VERSION_PATCH 439)
option(
WITH_LIBCXX
"Building with clang++ and libc++(in Linux). To enable with: -DWITH_LIBCXX=On"
On)
option(CODE_COVERAGE "Generate code coverage information files when running unit tests" OFF)
project(FOEDAG)
if(CODE_COVERAGE)
add_compile_options(--coverage)
add_link_options(--coverage)
endif()
set (BUILD_TYPE_STRING Engineering)
if (PRODUCTION_BUILD)
message("Production Build type set to ON")
set (PRODUCTION_BUILD_FLAG "-DPRODUCTION_BUILD=1")
add_definitions(-DPRODUCTION_BUILD)
set (BUILD_TYPE_STRING Production)
endif(PRODUCTION_BUILD)
# Check system
message("CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}")
if (MONACO_EDITOR)
message("Using Monaco Editor")
set(USE_MONACO_EDITOR ON CACHE BOOL "" FORCE)
else(MONACO_EDITOR)
message("Using QScintilla Editor")
set(USE_MONACO_EDITOR OFF CACHE BOOL "" FORCE)
endif(MONACO_EDITOR)
if (IPA)
message("Enable Interactive Path Analysis Tool")
set(USE_IPA ON CACHE BOOL "" FORCE)
add_definitions(-DUSE_IPA)
else(IPA)
message("Disable Interactive Path Analysis Tool")
set(USE_IPA OFF CACHE BOOL "" FORCE)
endif(IPA)
include(cmake/cmake_qt.txt)
# NOTE: Policy changes has to happen before adding any subprojects
cmake_policy(SET CMP0091 NEW)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
add_subdirectory(third_party/tcl_cmake EXCLUDE_FROM_ALL)
add_subdirectory(third_party/googletest EXCLUDE_FROM_ALL)
if (USE_MONACO_EDITOR)
add_subdirectory(third_party/monaco-editor)
else()
add_subdirectory(third_party/QScintilla-2.13.1)
endif()
add_subdirectory(third_party/QConsole)
add_subdirectory(third_party/nlohmann_json)
add_subdirectory(third_party/gtkwave_cmake)
add_subdirectory(third_party/scope_guard)
add_subdirectory(third_party/openocd_cmake)
add_subdirectory(third_party/openssl_cmake)
add_subdirectory(tests/tclutils)
add_subdirectory(tests/unittest)
add_subdirectory(src/NewProject)
add_subdirectory(src/NewFile)
add_subdirectory(src/ProjNavigator)
add_subdirectory(src/DesignRuns)
add_subdirectory(src/Console)
add_subdirectory(src/Main)
add_subdirectory(src/Compiler)
add_subdirectory(src/Simulation)
add_subdirectory(src/IPGenerate)
add_subdirectory(src/DesignQuery)
add_subdirectory(src/DeviceModeling)
add_subdirectory(src/TextEditor)
add_subdirectory(src/Utils)
add_subdirectory(src/IpConfigurator)
add_subdirectory(src/PinAssignment)
add_subdirectory(src/Configuration)
add_subdirectory(src/ProgrammerGui)
add_subdirectory(src/rapidgpt)
if (USE_IPA)
add_subdirectory(src/InteractivePathAnalysis)
endif()
# NOTE: Set the global output directories after the subprojects have had their go at it
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
set(FOEDAG_WITH_PYTHON ON)
# Python
if (FOEDAG_WITH_PYTHON)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/")
find_package(CustomPython3 REQUIRED)
message(STATUS "Python3_LIBRARIES (main) = ${Python3_LIBRARIES}")
message(STATUS "Python3_EXECUTABLE (main) = ${Python3_EXECUTABLE}")
message(STATUS "Python3_INCLUDE_DIRS (main) = ${Python3_INCLUDE_DIRS}")
message(STATUS "Python3_RUNTIME_LIBRARY_DIRS (main) = ${Python3_RUNTIME_LIBRARY_DIRS}")
endif()
if(NOT NO_TCMALLOC)
find_library(TCMALLOC_LIBRARY NAMES tcmalloc)
if(TCMALLOC_LIBRARY)
set(TCMALLOC_COMPILE_OPTIONS
"-fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free"
)
endif()
endif()
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} ${TCMALLOC_COMPILE_OPTIONS} ${MY_CXX_WARNING_FLAGS}")
if(MSVC)
add_subdirectory(third_party/zlib) # Do not use EXCLUDE_FROM_ALL else unit tests will fail for this subsystem
add_compile_definitions(_CRT_NONSTDC_NO_WARNINGS)
set(CMAKE_CXX_FLAGS_DEBUG
"${CMAKE_CXX_FLAGS_DEBUG} ${TCMALLOC_COMPILE_OPTIONS} /Zc:__cplusplus /W0 /bigobj /Zl /GL- /MT /DSTATIC_BUILD ${MY_CXX_WARNING_FLAGS}"
)
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO
"${CMAKE_CXX_FLAGS_RELEASE} ${TCMALLOC_COMPILE_OPTIONS} /Zc:__cplusplus /W0 /bigobj /Zl /GL- /MT /DSTATIC_BUILD ${MY_CXX_WARNING_FLAGS}"
)
set(CMAKE_CXX_FLAGS_RELEASE
"${CMAKE_CXX_FLAGS_RELEASE} ${TCMALLOC_COMPILE_OPTIONS} /Zc:__cplusplus /W0 /bigobj /Zl /GL- /MT /DSTATIC_BUILD ${MY_CXX_WARNING_FLAGS}"
)
set(CMAKE_EXE_LINKER_FLAGS /STACK:8388608) # 8MB stack size
else()
if(DEFINED ENV{MSYSTEM})
# Under MSYS some files are too large to build without additional flags
set(MSYS_COMPILE_OPTIONS "-m64 -Wa,-mbig-obj")
endif()
if (SANITIZE)
set(MEM_SANITIZER_FLAGS "-fsanitize=address -fno-omit-frame-pointer")
endif()
set(CMAKE_CXX_FLAGS_DEBUG
"${CMAKE_CXX_FLAGS_DEBUG} ${TCMALLOC_COMPILE_OPTIONS} -Werror -Wall -O0 -g ${MSYS_COMPILE_OPTIONS} ${MY_CXX_WARNING_FLAGS} ${MEM_SANITIZER_FLAGS} ${PRODUCTION_BUILD_FLAG}"
)
set(CMAKE_CXX_FLAGS_RELEASE
"${CMAKE_CXX_FLAGS_RELEASE} ${TCMALLOC_COMPILE_OPTIONS} -Werror -Wall -O3 ${MSYS_COMPILE_OPTIONS} -DNDEBUG ${MY_CXX_WARNING_FLAGS} ${PRODUCTION_BUILD_FLAG}"
)
endif()
include_directories(${PROJECT_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR}/include/)
set(QRC_MAIN_WINDOW
src/MainWindow/main_window_resource.qrc
# src/MainWindow/qml.qrc
${PROJECT_SOURCE_DIR}/src/NewProject/newproject.qrc)
# Put source code here, files that are generated at build time in
# foedag_generated_SRC
set(foedag_SRC
${QRC_MAIN_WINDOW}
)
add_library(foedag STATIC ${foedag_SRC})
set_target_properties(foedag PROPERTIES PUBLIC_HEADER src/Main/Foedag.h)
target_include_directories(foedag PRIVATE
${CMAKE_CURRENT_BINARY_DIR}/include
third_party/googletest/googletest/include
third_party/googletest/googlemock/include)
target_include_directories(foedag PUBLIC $<INSTALL_INTERFACE:include/foedag>)
if(MSVC)
add_executable(foedag-bin ${PROJECT_SOURCE_DIR}/src/Main/main.cpp ${QRC_MAIN_WINDOW})
set_property(TARGET foedag-bin PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
set_property(TARGET foedag-bin PROPERTY COMPILER_FLAGS /DSTATIC_BUILD)
else()
add_executable(foedag-bin ${PROJECT_SOURCE_DIR}/src/Main/main.cpp ${QRC_MAIN_WINDOW})
endif()
set_target_properties(foedag-bin PROPERTIES OUTPUT_NAME foedag)
if (MSVC)
message("WINDOWS MODE")
set(TCL_STUBB_LIB tclstub86.lib)
set(TCL_STATIC_LIB tcl86ts.lib)
set(ZLIB_STATIC_LIB zlib.lib)
add_library(tcl_static STATIC IMPORTED )
set_target_properties(tcl_static PROPERTIES
IMPORTED_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/lib/${TCL_STATIC_LIB})
else()
set(TCL_STATIC_LIB libtcl8.6.so)
set(TCL_STUBB_LIB libtclstub8.6.a)
set(ZLIB_STATIC_LIB libz.a)
if(APPLE)
set(TCL_STATIC_LIB libtcl8.6.dylib)
endif()
link_directories(${CMAKE_CURRENT_BINARY_DIR}/lib/)
if((DEFINED ENV{MSYSTEM}) AND ("$ENV{MSYSTEM}" STREQUAL "MINGW64"))
message("MSYS MODE")
set(TCL_STATIC_LIB libtcl86.dll.a)
set(TCL_STUBB_LIB libtclstub86.a)
set(ZLIB_STATIC_LIB libzlibstatic.a)
add_library(tcl_static STATIC IMPORTED )
set_target_properties(tcl_static PROPERTIES
IMPORTED_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/lib/${TCL_STATIC_LIB})
else()
message("LINUX MODE")
get_filename_component(buildDirRelFilePath ${TCL_STATIC_LIB}
REALPATH BASE_DIR ${CMAKE_CURRENT_BINARY_DIR}/lib)
add_library(tcl_static SHARED IMPORTED )
find_library(tcl_static PATHS ${CMAKE_CURRENT_BINARY_DIR}/lib/)
set_target_properties(tcl_static PROPERTIES
IMPORTED_LOCATION ${buildDirRelFilePath} IMPORTED_NO_SONAME ON)
endif()
endif()
add_library(tcl_stubb STATIC IMPORTED )
set_target_properties(tcl_stubb PROPERTIES
IMPORTED_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/lib/${TCL_STUBB_LIB})
if(MSVC)
set_target_properties(tcl_static PROPERTIES
COMPILE_OPTIONS "$<$<CONFIG:Debug>:/MTd>$<$<CONFIG:Release>:/MT>"
)
set_target_properties(tcl_stubb PROPERTIES
COMPILE_OPTIONS "$<$<CONFIG:Debug>:/MTd>$<$<CONFIG:Release>:/MT>"
)
# Do not add zlib library, it is imported above
set_target_properties(foedag PROPERTIES
COMPILE_OPTIONS "$<$<CONFIG:Debug>:/MTd>$<$<CONFIG:Release>:/MT>"
)
target_link_libraries(foedag-bin PUBLIC Netapi32)
target_link_libraries(foedag PUBLIC Netapi32)
else()
add_library(zlib STATIC IMPORTED)
set_target_properties(zlib PROPERTIES
IMPORTED_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/lib/${ZLIB_STATIC_LIB})
endif()
# Copy the init.tcl file from source to build directory
add_custom_command(TARGET foedag POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_SOURCE_DIR}/third_party/tcl8.6.12/library/init.tcl
${CMAKE_CURRENT_BINARY_DIR}/lib/tcl8.6/init.tcl)
execute_process(COMMAND git config --global --add safe.directory ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND git rev-parse --short HEAD
OUTPUT_VARIABLE GIT_HASH
ERROR_VARIABLE GIT_HASH_ERR
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
if ("${GIT_HASH_ERR}" STREQUAL "")
string(STRIP "${GIT_HASH}" GIT_HASH)
message(STATUS "GIT_HASH = ${GIT_HASH}")
else()
message(FATAL_ERROR "${GIT_HASH_ERR}")
endif()
message(STATUS "BUILD_TYPE_STRING = ${BUILD_TYPE_STRING}")
if("${STICK_RELEASE_VERSION}" STREQUAL "")
string(TIMESTAMP CURRENT_DATE "%Y-%m-%d" UTC)
string(SUBSTRING "${CURRENT_DATE}" 0 4 RELEASE_YEAR)
string(SUBSTRING "${CURRENT_DATE}" 5 2 RELEASE_MONTH)
set(RELEASE_VERSION ${RELEASE_YEAR}.${RELEASE_MONTH})
else()
set(RELEASE_VERSION ${STICK_RELEASE_VERSION})
endif()
configure_file(foedag_version.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/foedag_version.h)
# Explicit lib build order
add_dependencies(foedag foedagcore)
add_dependencies(compiler foedag_nlohmann_json)
add_dependencies(compiler tcl_stubb_build)
add_dependencies(simulation tcl_stubb_build)
add_dependencies(ipgenerate tcl_stubb_build)
add_dependencies(designquery tcl_stubb_build)
add_dependencies(designquery foedag_nlohmann_json)
add_dependencies(devicemodeling tcl_stubb_build)
add_dependencies(devicemodeling foedag_nlohmann_json)
add_dependencies(projnavigator foedag_nlohmann_json)
add_dependencies(newproject foedag_nlohmann_json)
add_dependencies(foedagcore tcl_stubb_build)
add_dependencies(console tcl_stubb_build)
add_dependencies(console tcl_static)
add_dependencies(newproject tcl_stubb_build)
add_dependencies(tcl_stubb_build tcl_build)
add_dependencies(console QConsole)
add_dependencies(tclutils tcl_stubb_build)
add_dependencies(newproject foedag_nlohmann_json)
if(MSVC)
else()
add_dependencies(tcl_build zlib_build)
endif()
if (USE_MONACO_EDITOR)
add_dependencies(texteditor tcl_build)
else()
add_dependencies(foedagcore qscintilla2_qt)
add_dependencies(texteditor qscintilla2_qt tcl_build)
endif()
add_dependencies(designruns tcl_build)
add_dependencies(tcl_static tcl_build)
add_dependencies(foedag-bin tcl_build)
add_dependencies(designruns_bin tcl_build)
add_dependencies(foedagcore tcl_build)
add_dependencies(console_debug tcl_build)
add_dependencies(newfile tcl_stubb_build)
add_dependencies(newfile_bin tcl_stubb_build)
add_dependencies(ipconfigurator tcl_stubb_build)
add_dependencies(ipconfigurator_bin tcl_stubb_build)
add_dependencies(pinassignment tcl_stubb_build)
add_dependencies(projnavigator tcl_build)
add_dependencies(rapidgpt tcl_build)
add_dependencies(configuration openssl_lib_test)
if(USE_IPA)
if(MSVC)
add_dependencies(interactive_path_analysis zlib)
endif(MSVC)
add_dependencies(foedagcore interactive_path_analysis)
add_dependencies(interactive_path_analysis compiler)
endif(USE_IPA)
if (APPLE)
# In macOS, it is necessary to add the correct @rpath to the executable for
# finding python dynamic libraries ref: https://gitlab.kitware.com/cmake/cmake/-/issues/21293
# https://gitlab.kitware.com/cmake/cmake/-/issues/21947
# Python3_LINK_OPTIONS is variable available from cmake 3.19, update cmake using homebrew
# if can't update cmake use:
# set_target_properties(foedag-bin PROPERTIES BUILD_WITH_INSTALL_RPATH TRUE
# INSTALL_RPATH "/Library/Developer/CommandLineTools/Library/Frameworks/")
# if you installed python with hombrew. Or if you install python with Xcode:
# set_target_properties(foedag-bin PROPERTIES BUILD_WITH_INSTALL_RPATH TRUE
# INSTALL_RPATH "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/")
target_link_libraries(foedag-bin PUBLIC foedag "-framework CoreFoundation")
target_link_libraries(foedag PUBLIC "-framework CoreFoundation")
endif()
if(MSVC OR WIN32)
# We have two files named "foedag.lib" and both getting generated in the lib folder
# One is the foedag.lib generated by the foedag target and the other is the one generated
# because of /IMPLIB option when linking the executable. Unfortunately, there is no documented
# way to disable the latter in CMake. So, moving the library to the bin directory (right next to the exe)
set_target_properties(foedag-bin PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
endif()
target_link_libraries(foedag-bin PUBLIC foedag )
target_link_directories(foedag-bin PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/lib PUBLIC ${CMAKE_INSTALL_PREFIX}/lib/foedag/lib)
target_link_libraries(foedag PUBLIC
foedagcore
newproject
newfile
projnavigator
designruns
texteditor
compiler
ipgenerate
designquery
devicemodeling
simulation
foedagutils
console
QConsole
tcl_stubb
tcl_static
zlib
ipconfigurator
pinassignment
scope_guard
cfgcompiler
rapidgpt
)
if (USE_MONACO_EDITOR)
else()
target_link_libraries(foedag PUBLIC
qscintilla2_qt
)
endif()
target_link_libraries(foedag PUBLIC Qt6::Widgets Qt6::Core Qt6::Gui Qt6::Xml)
if(NOT NO_TCMALLOC)
find_library(TCMALLOC_LIBRARY NAMES tcmalloc)
if(TCMALLOC_LIBRARY)
target_link_libraries(foedag PRIVATE tcmalloc)
endif()
endif()
if (UNIX)
target_link_libraries(foedag PRIVATE dl)
target_link_libraries(foedag PRIVATE util)
target_link_libraries(foedag PRIVATE m)
target_link_libraries(foedag PRIVATE pthread)
endif()
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
target_link_libraries(foedag PRIVATE stdc++fs)
target_link_libraries(foedag PRIVATE rt)
endif()
# Unit tests
if(MSVC)
# Microsoft reports the value of __cplusplus wrong and gmock/gtest pulls in the
# string_view implementation based on it's value. Microsoft's solution is to
# provide additional flags to make the value correct. More info can be found here -
#
# https://docs.microsoft.com/en-us/cpp/build/reference/zc-cplusplus?view=msvc-160
# https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/
target_compile_options(gmock PRIVATE /Zc:__cplusplus)
target_compile_options(gmock_main PRIVATE /Zc:__cplusplus)
target_compile_options(gtest PRIVATE /Zc:__cplusplus)
target_compile_options(gtest_main PRIVATE /Zc:__cplusplus)
endif()
if (WIN32 OR APPLE)
else ()
# The test works, the CI running headlessly does not
# register_gtests(src/Main/GuiMain_test.cpp)
endif()
# Installation target
install(
TARGETS foedag-bin
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
install(
TARGETS foedag
EXPORT Foedag
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/foedag
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/foedag)
install (
FILES ${CMAKE_CURRENT_BINARY_DIR}/lib/${TCL_STATIC_LIB}
DESTINATION ${CMAKE_INSTALL_LIBDIR}/foedag/lib)
install (
FILES ${CMAKE_CURRENT_BINARY_DIR}/lib/${TCL_STUBB_LIB}
DESTINATION ${CMAKE_INSTALL_LIBDIR}/foedag/lib)
install (
FILES ${CMAKE_CURRENT_BINARY_DIR}/lib/${ZLIB_STATIC_LIB}
DESTINATION ${CMAKE_INSTALL_LIBDIR}/foedag/lib)
if(MSVC)
set(VCPKG_LIBUSB_DIR "$ENV{VCPKG_INSTALLATION_ROOT}/packages/libusb_x64-windows")
file(TO_CMAKE_PATH "${VCPKG_LIBUSB_DIR}" VCPKG_LIBUSB_DIR)
set(libusb_dll "${VCPKG_LIBUSB_DIR}/bin/libusb-1.0.dll")
add_custom_target(copy_libusb_dll_to_bin
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${libusb_dll} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
DEPENDS ${libusb_dll}
)
add_dependencies(foedag-bin copy_libusb_dll_to_bin)
install(
FILES ${libusb_dll}
DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
if (WIN32 AND $<CONFIG:Debug>)
if (FOEDAG_WITH_PYTHON)
install(
FILES $<TARGET_PDB_FILE:foedag-bin>
${Python3_RUNTIME_LIBRARY_DIRS}/python${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR}$<$<CONFIG:Debug>:_d>.dll
DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/foedag.dir/foedag.pdb
${TCL_BINARY_DIR}/runtime/CMakeFiles/tcl_static.dir/tcl_static.pdb
${TCL_BINARY_DIR}/runtime/CMakeFiles/tcl_stubb.dir/tcl_stubb.pdb
DESTINATION ${CMAKE_INSTALL_LIBDIR}/foedag)
endif()
if ((DEFINED ENV{MSYSTEM}) AND ("$ENV{MSYSTEM}" STREQUAL "MINGW64"))
# we do not have the TCL header files to 'install' as we don't build it.
# we just use the TCL MinGW64 lib.
else()
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/include/tcl.h
${CMAKE_CURRENT_BINARY_DIR}/include/tclDecls.h
${CMAKE_CURRENT_BINARY_DIR}/include/tclPlatDecls.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/foedag/include)
endif()
# install(
# EXPORT Foedag
# FILE Foedag.cmake
# DESTINATION cmake)
include(CMakePackageConfigHelpers)
# generate the config file that is includes the exports
configure_package_config_file(
${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/FoedagConfig.cmake"
INSTALL_DESTINATION cmake
NO_SET_AND_CHECK_MACRO
NO_CHECK_REQUIRED_COMPONENTS_MACRO)
# install the configuration file
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/FoedagConfig.cmake
DESTINATION cmake)
install(
DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/share/foedag/etc/ DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/foedag/etc/)
install(
DIRECTORY tests/Testcases/IPGenerate/IP_Catalog DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/foedag)
install(
DIRECTORY examples DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/foedag)
install(
DIRECTORY tests/Arch/ DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/foedag/Arch/)
install(
DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin/gtkwave DESTINATION ${CMAKE_INSTALL_BINDIR}
USE_SOURCE_PERMISSIONS
)
install(
DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/share/foedag/configuration DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/foedag)
install(
PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/bin/openocd${CMAKE_EXECUTABLE_SUFFIX}
DESTINATION ${CMAKE_INSTALL_BINDIR}
)
if (MSVC OR WIN32 OR APPLE)
else ()
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/bin/foedag.exe
DESTINATION ${CMAKE_INSTALL_BINDIR}
PERMISSIONS
OWNER_READ OWNER_EXECUTE OWNER_WRITE
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE
)
endif()
install(
FILES src/foedagenv_lin64.sh
src/.foedagenv_lin64.sh
DESTINATION ${CMAKE_INSTALL_BINDIR}/..
PERMISSIONS
OWNER_READ OWNER_EXECUTE OWNER_WRITE
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE
)
if ((DEFINED ENV{MSYSTEM}) AND ("$ENV{MSYSTEM}" STREQUAL "MINGW64"))
# permission problems in windows at this point.
else()
add_custom_target(link_target ALL
COMMAND ${CMAKE_COMMAND} -E create_symlink
build/compile_commands.json ../compile_commands.json)
endif()
add_custom_command(TARGET foedag-bin POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/share/foedag/IP_Catalog/
COMMAND ${CMAKE_COMMAND} -E copy_directory
${PROJECT_SOURCE_DIR}/tests/Testcases/IPGenerate/IP_Catalog
${CMAKE_CURRENT_BINARY_DIR}/share/foedag/IP_Catalog)
add_custom_command(TARGET foedag-bin POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/share/foedag/examples/
COMMAND ${CMAKE_COMMAND} -E copy_directory
${PROJECT_SOURCE_DIR}/examples
${CMAKE_CURRENT_BINARY_DIR}/share/foedag/examples/)
add_custom_command(TARGET foedag-bin POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/share/foedag/etc/
COMMAND ${CMAKE_COMMAND} -E copy_directory
${PROJECT_SOURCE_DIR}/etc/
${CMAKE_CURRENT_BINARY_DIR}/share/foedag/etc/)
add_custom_command(TARGET foedag-bin POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_SOURCE_DIR}/LICENSE
${CMAKE_CURRENT_BINARY_DIR}/share/foedag/etc/)
add_custom_command(TARGET foedag-bin POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/share/foedag/Arch/
COMMAND ${CMAKE_COMMAND} -E copy_directory
${PROJECT_SOURCE_DIR}/tests/Arch
${CMAKE_CURRENT_BINARY_DIR}/share/foedag/Arch/)
if (MSVC OR WIN32 OR APPLE)
else ()
add_custom_command(TARGET foedag-bin POST_BUILD
COMMAND echo "rename foedag binary as foedag.exe"
COMMAND ${CMAKE_COMMAND} -E rename
${CMAKE_CURRENT_BINARY_DIR}/bin/foedag
${CMAKE_CURRENT_BINARY_DIR}/bin/foedag.exe)
add_custom_command(TARGET foedag-bin POST_BUILD
COMMAND echo "copy to_be_foedag_lnx as foedag"
COMMAND ${CMAKE_COMMAND} -E copy
${PROJECT_SOURCE_DIR}/src/to_be_foedag_linx
${CMAKE_CURRENT_BINARY_DIR}/bin/foedag
COMMAND ${CMAKE_COMMAND} -E copy
${PROJECT_SOURCE_DIR}/src/.foedagenv_lin64.sh
${CMAKE_CURRENT_BINARY_DIR})
endif()