create regress_simple for JavaScript
[liba.git] / CMakeLists.txt
blob223c36cad1754b6ee3a471848b4627f6c2c6af13
1 set(CMAKE_POLICY_DEFAULT_CMP0048 NEW)
2 set(CMAKE_POLICY_DEFAULT_CMP0063 NEW)
3 cmake_minimum_required(VERSION 2.8.12...4.0)
4 include(cmake/CMakeModulePath.cmake)
5 include(cmake/Languages.cmake)
6 project(liba ${LANGUAGES})
7 include(cmake/Project.cmake)
8 include(cmake/core/file.cmake)
9 include(cmake/core/string.cmake)
10 include(cmake/CMakeByteOrder.cmake)
11 include(cmake/CMakeBuildType.cmake)
12 include(cmake/EnabledLanguages.cmake)
13 include(cmake/TargetSupportsSharedLibs.cmake)
14 include(cmake/TargetSupportsExecutables.cmake)
15 include(cmake/TargetSupportsSymbolicLink.cmake)
17 option(LIBA_STATIC "Enable/Disable finding and linking static libraries" 0)
19 if(LIBA_STATIC)
20   include(cmake/CMakeFindLibraryStatic.cmake)
21 endif()
23 option(LIBA_WARNINGS "Enable/Disable warnings" 0)
25 if(LIBA_WARNINGS)
26   include(cmake/TargetWarnings.cmake)
27 endif()
29 option(LIBA_ANALYZER "Enable/Disable analyzer" 0)
31 if(LIBA_ANALYZER)
32   include(cmake/TargetAnalyzer.cmake)
33 endif()
35 option(LIBA_SANITIZE "Enable/Disable sanitize" 0)
37 if(LIBA_SANITIZE)
38   include(cmake/TargetSanitize.cmake)
39 endif()
41 if(LIBA_STATIC)
42   include(cmake/TargetStatic.cmake)
43 endif()
45 option(LIBA_CCACHE "Enable/Disable ccache" 0)
47 if(LIBA_CCACHE)
48   include(cmake/UseCCache.cmake)
49 endif()
51 if(UNIX)
52   set(LIBA_MATH "m" CACHE FILEPATH "system math library")
53 else()
54   set(LIBA_MATH "" CACHE FILEPATH "system math library")
55 endif()
57 set(LIBA_INSTALL "" CACHE STRING "Specify installation behavior")
58 set(LIBA_FLOAT 8 CACHE STRING "floating-point number bytes")
59 set_property(CACHE LIBA_FLOAT PROPERTY STRINGS 4 8 16)
60 include(CheckLibraryExists)
62 function(check_math VARIABLE FUNCTION)
63   get_filename_component(LOCATION "${LIBA_MATH}" DIRECTORY)
64   list(APPEND CMAKE_REQUIRED_LIBRARIES ${LIBA_MATH})
66   if(LIBA_FLOAT GREATER 8)
67     set(FUNCTION ${FUNCTION}l)
68   elseif(LIBA_FLOAT EQUAL 4)
69     set(FUNCTION ${FUNCTION}f)
70   endif()
72   check_library_exists("${LIBA_MATH}"
73     ${FUNCTION} "${LOCATION}" ${VARIABLE}
74   )
75 endfunction()
77 check_math(A_HAVE_EXPM1 expm1)
78 check_math(A_HAVE_LOG1P log1p)
79 check_math(A_HAVE_HYPOT hypot)
80 check_math(A_HAVE_ATAN2 atan2)
81 check_math(A_HAVE_CSQRT csqrt)
82 check_math(A_HAVE_CPOW cpow)
83 check_math(A_HAVE_CEXP cexp)
84 check_math(A_HAVE_CLOG clog)
85 check_math(A_HAVE_CSIN csin)
86 check_math(A_HAVE_CCOS ccos)
87 check_math(A_HAVE_CTAN ctan)
88 check_math(A_HAVE_CSINH csinh)
89 check_math(A_HAVE_CCOSH ccosh)
90 check_math(A_HAVE_CTANH ctanh)
91 check_math(A_HAVE_CASIN casin)
92 check_math(A_HAVE_CACOS cacos)
93 check_math(A_HAVE_CATAN catan)
94 check_math(A_HAVE_CASINH casinh)
95 check_math(A_HAVE_CACOSH cacosh)
96 check_math(A_HAVE_CATANH catanh)
98 option(LIBA_DOXYGEN "Enable/Disable doxygen" 0)
100 if(LIBA_DOXYGEN)
101   find_package(Doxygen OPTIONAL_COMPONENTS dot mscgen dia)
102 endif()
104 option(LIBA_CPPCHECK "Enable/Disable cppcheck" 0)
106 if(LIBA_CPPCHECK)
107   find_package(Cppcheck)
108 endif()
110 option(LIBA_CLANG_TIDY "Enable/Disable clang-tidy" 0)
112 if(LIBA_CLANG_TIDY)
113   find_package(ClangTidy)
114 endif()
116 option(LIBA_IWYU "Enable/Disable include-what-you-use" 0)
118 if(LIBA_IWYU)
119   find_package(IWYU)
120 endif()
122 option(LIBA_IPO "Enable/Disable interprocedural optimization" 0)
124 # https://cmake.org/cmake/help/latest/module/CheckIPOSupported.html
125 if(NOT CMAKE_VERSION VERSION_LESS 3.9 AND LIBA_IPO)
126   cmake_policy(SET CMP0069 NEW)
127   include(CheckIPOSupported)
128   check_ipo_supported(RESULT LIBA_IPO)
129 endif()
131 if(DEFINED ENV{ANDROID_ROOT} AND EXISTS $ENV{ANDROID_ROOT})
132   option(LIBA_PIE "Enable/Disable position independent code" 1)
133 else()
134   option(LIBA_PIE "Enable/Disable position independent code" 0)
135 endif()
137 # https://cmake.org/cmake/help/latest/module/CheckPIESupported.html
138 if(NOT CMAKE_VERSION VERSION_LESS 3.14)
139   cmake_policy(SET CMP0083 NEW)
140   include(CheckPIESupported)
141   check_pie_supported()
142 endif()
144 function(set_library_options)
145   if(LIBA_IWYU AND IWYU_FOUND)
146     add_include_what_you_use(TARGETS ${ARGN})
147   endif()
149   if(LIBA_CLANG_TIDY AND CLANG_TIDY_FOUND)
150     add_clang_tidy(TARGETS ${ARGN} OPTIONS --fix)
151   endif()
153   if(LIBA_CPPCHECK AND CPPCHECK_FOUND)
154     add_cppcheck(TARGETS ${ARGN} OPTIONS --enable=warning,performance)
155   endif()
157   set_target_properties(${ARGN} PROPERTIES INTERPROCEDURAL_OPTIMIZATION ${LIBA_IPO}
158     C_VISIBILITY_PRESET hidden CXX_VISIBILITY_PRESET hidden VISIBILITY_INLINES_HIDDEN 1
159   )
161   if(CMAKE_C_COMPILER_ID MATCHES "TinyCC" AND CMAKE_STATIC_LIBRARY_SUFFIX STREQUAL .lib)
162     set_property(TARGET ${ARGN} PROPERTY IMPORT_SUFFIX .def)
163   endif()
165   if(LIBA_WARNINGS)
166     target_compile_warnings(${ARGN})
167   endif()
169   if(LIBA_ANALYZER)
170     target_compile_analyzer(${ARGN})
171   endif()
172 endfunction()
174 function(add_library_properties target scope source)
175   target_compile_definitions(${target} ${scope} $<TARGET_PROPERTY:${source},${ARGV3}COMPILE_DEFINITIONS>)
176   target_include_directories(${target} ${scope} $<TARGET_PROPERTY:${source},${ARGV3}INCLUDE_DIRECTORIES>)
178   if(${scope} MATCHES "PUBLIC|PRIVATE")
179     set_property(TARGET ${target} APPEND PROPERTY LINK_LIBRARIES $<TARGET_PROPERTY:${source},${ARGV3}LINK_LIBRARIES>)
180   endif()
182   if(${scope} MATCHES "PUBLIC|INTERFACE")
183     set_property(TARGET ${target} APPEND PROPERTY INTERFACE_LINK_LIBRARIES $<TARGET_PROPERTY:${source},${ARGV3}LINK_LIBRARIES>)
184   endif()
185 endfunction()
187 option(LIBA_MIMALLOC "Enable/Disable override using mimalloc" 0)
189 if(LIBA_MIMALLOC)
190   find_package(mimalloc)
191 endif()
193 if(mimalloc_FOUND)
194   if(TARGET mimalloc-static)
195     set(MIMALLOC_LIBRARY mimalloc-static)
196   else()
197     set(MIMALLOC_LIBRARY mimalloc)
198   endif()
199 endif()
201 if(EXISTS ${CMAKE_CURRENT_LIST_DIR}/.git)
202   find_package(Git)
204   if(GIT_FOUND)
205     function(git_command output)
206       execute_process(ERROR_QUIET
207         COMMAND ${GIT_EXECUTABLE} ${ARGN}
208         OUTPUT_STRIP_TRAILING_WHITESPACE
209         OUTPUT_VARIABLE ${output}
210       )
211       set(${output} ${${output}} PARENT_SCOPE)
212     endfunction()
214     git_command(GIT_COMMIT_LONG log -1 --pretty=format:%H)
215     git_command(GIT_COMMIT_DATE log -1 --pretty=format:%cd --date=format:%Y%m%d)
216   endif()
218   if(GIT_COMMIT_DATE)
219     set(${PROJECT_NAME}_VERSION_TWEAK ${GIT_COMMIT_DATE})
220     set(PROJECT_VERSION_TWEAK ${GIT_COMMIT_DATE})
221     set(A_VERSION_TWEAK ${GIT_COMMIT_DATE})
222   endif()
223 endif()
225 if(NOT EXISTS "${A_HAVE_H}")
226   set(A_HAVE_H ${CMAKE_CURRENT_BINARY_DIR}/a.cmake.h)
227   configure_file(${CMAKE_CURRENT_LIST_DIR}/include/a.cmake.h.in ${A_HAVE_H})
228 endif()
230 if(IS_ABSOLUTE "${LIBA_MATH}")
231   get_filename_component(math ${LIBA_MATH} NAME_WE)
232   string(REGEX REPLACE "^${CMAKE_STATIC_LIBRARY_PREFIX}(.+)" "\\1" math "${math}")
233   set(LIBA_MATH $<BUILD_INTERFACE:${LIBA_MATH}> $<INSTALL_INTERFACE:${math}>)
234 endif()
236 if(TARGET_SUPPORTS_SYMBOLIC_LINK)
237   option(LIBA_SYMLINK "Enable/Disable symbolic link" 1)
238 endif()
240 function(set_library_compile target)
241   if(EXISTS "${A_HAVE_H}")
242     file(RELATIVE_PATH a_have_h ${PROJECT_SOURCE_DIR}/include/a ${A_HAVE_H})
243     target_compile_definitions(${target} PUBLIC $<BUILD_INTERFACE:A_HAVE_H="${a_have_h}">)
244   endif()
246   if((LIBA_SYMLINK OR WIN32) AND TARGET_SUPPORTS_SYMBOLIC_LINK)
247     set_target_properties(${target} PROPERTIES SOVERSION
248       ${PROJECT_VERSION_MAJOR} VERSION ${PROJECT_VERSION}
249     )
250   endif()
252   set_target_properties(${target} PROPERTIES OUTPUT_NAME a
253     POSITION_INDEPENDENT_CODE 1 DEFINE_SYMBOL A_EXPORTS
254   )
255   target_compile_definitions(${target} PRIVATE A_EXPORTS)
256   target_include_directories(${target} BEFORE PUBLIC
257     $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
258     $<INSTALL_INTERFACE:include>
259   )
260   get_property(TYPE TARGET ${target} PROPERTY TYPE)
262   if(${TYPE} MATCHES "(STATIC|SHARED|MODULE)_LIBRARY")
263     target_link_libraries(${target} PUBLIC ${LIBA_MATH})
264   endif()
266   set_library_options(${target})
267 endfunction()
269 if(LIBA_CXX)
270   file_scaner(SOURCES RECURSE include src EXT c h cc hh cpp hpp)
271 else()
272   file_scaner(SOURCES RECURSE include src EXT c h)
273 endif()
275 add_library(a OBJECT ${SOURCES})
276 set_library_compile(a)
278 if(LIBA_MIMALLOC AND mimalloc_FOUND)
279   set_property(SOURCE ${CMAKE_CURRENT_LIST_DIR}/src/a.c
280     APPEND PROPERTY COMPILE_DEFINITIONS A_HAVE_MIMALLOC_H
281   )
283   if(CMAKE_VERSION VERSION_LESS 3.12)
284     add_library_properties(a PUBLIC ${MIMALLOC_LIBRARY} INTERFACE_)
285   else()
286     target_link_libraries(a PUBLIC ${MIMALLOC_LIBRARY})
287   endif()
288 endif()
290 include(GNUInstallDirs)
291 set(INSTALL_TARGETS "")
293 if("${LIBA_INSTALL}" MATCHES "^$|static")
294   list(APPEND INSTALL_TARGETS alib)
295 endif()
297 add_library(alib STATIC $<TARGET_OBJECTS:a>)
298 set_library_compile(alib)
300 if(LIBA_MIMALLOC AND mimalloc_FOUND)
301   target_link_libraries(alib PUBLIC ${MIMALLOC_LIBRARY})
302 endif()
304 if(TARGET_SUPPORTS_SHARED_LIBS)
305   if("${LIBA_INSTALL}" MATCHES "^$|shared")
306     list(APPEND INSTALL_TARGETS liba)
307   endif()
309   add_library(liba SHARED $<TARGET_OBJECTS:a>)
310   set_library_compile(liba)
312   if(LIBA_MIMALLOC AND mimalloc_FOUND)
313     target_link_libraries(liba PUBLIC ${MIMALLOC_LIBRARY})
314   endif()
316   if(CMAKE_STATIC_LIBRARY_SUFFIX STREQUAL .lib)
317     set_property(TARGET liba PROPERTY OUTPUT_NAME liba)
318   endif()
320   target_compile_definitions(liba INTERFACE A_IMPORTS)
322   if(LIBA_STATIC)
323     target_link_static(liba)
324   endif()
325 endif()
327 if(LIBA_SANITIZE)
328   add_library(asan OBJECT ${SOURCES})
329   set_library_compile(asan)
330   target_compile_sanitize(asan)
332   if(LIBA_MIMALLOC AND mimalloc_FOUND)
333     if(CMAKE_VERSION VERSION_LESS 3.12)
334       add_library_properties(asan PUBLIC ${MIMALLOC_LIBRARY} INTERFACE_)
335     else()
336       target_link_libraries(asan PUBLIC ${MIMALLOC_LIBRARY})
337     endif()
338   endif()
339 endif()
341 if(INSTALL_TARGETS)
342   include(cmake/InstallTargets.cmake)
343   install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/include/a DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
345   if(EXISTS "${A_HAVE_H}")
346     install(FILES ${A_HAVE_H} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/a)
347     install_hook(${CMAKE_INSTALL_INCLUDEDIR}/a/a.h A_HAVE_H ${A_HAVE_H})
348   endif()
349 endif()
351 option(LIBA_PKGCONFIG "Enable/Disable pkgconfig" 0)
353 if(LIBA_PKGCONFIG)
354   include(cmake/InstallPkgConfig.cmake)
355   install_pkgconfig(${PROJECT_NAME} alib)
356 endif()
358 option(LIBA_LIBTOOL "Enable/Disable libtool" 0)
360 if(LIBA_LIBTOOL AND INSTALL_TARGETS)
361   include(cmake/InstallLibtool.cmake)
362   install_libtool(${INSTALL_TARGETS})
363 endif()
365 set(LIBA_VCPKG "" CACHE PATH "vcpkg installation root")
367 if(EXISTS ${CMAKE_CURRENT_LIST_DIR}/vcpkg AND LIBA_VCPKG AND GIT_COMMIT_LONG)
368   if(NOT EXISTS ${LIBA_VCPKG})
369     set(LIBA_VCPKG ${CMAKE_CURRENT_BINARY_DIR}/vcpkg)
370     install(DIRECTORY ${LIBA_VCPKG} DESTINATION ${CMAKE_INSTALL_DATADIR})
371   endif()
373   configure_file(
374     ${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/portfile.cmake
375     ${LIBA_VCPKG}/ports/${PROJECT_NAME}/portfile.cmake
376     @ONLY
377   )
378   configure_file(
379     ${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/vcpkg.json
380     ${LIBA_VCPKG}/ports/${PROJECT_NAME}/vcpkg.json
381     @ONLY
382   )
383 endif()
385 if(PROJECT_IS_TOP_LEVEL)
386   add_custom_target(afmt)
387   add_custom_target(adoc)
388   include(CTest)
389 endif()
391 if(NOT CMAKE_FIND_LIBRARY_PREFIXES)
392   set(CMAKE_FIND_LIBRARY_PREFIXES ";lib")
393 endif()
395 if(EXISTS ${CMAKE_CURRENT_LIST_DIR}/java/CMakeLists.txt)
396   option(LIBA_JAVA "Enable/Disable java" 0)
398   if(LIBA_JAVA)
399     find_package(Java)
400     find_package(JNI)
401   endif()
403   if(LIBA_JAVA AND Java_JAVAC_EXECUTABLE)
404     add_subdirectory(java)
405   endif()
406 endif()
408 if(EXISTS ${CMAKE_CURRENT_LIST_DIR}/javascript/CMakeLists.txt)
409   if(EMSCRIPTEN)
410     option(LIBA_JAVASCRIPT "Enable/Disable javascript" 1)
411   else()
412     option(LIBA_JAVASCRIPT "Enable/Disable javascript" 0)
413   endif()
415   if(LIBA_JAVASCRIPT)
416     if(NOT EMSCRIPTEN)
417       find_package(Emscripten)
418     endif()
420     if(EMSCRIPTEN OR EMSCRIPTEN_FOUND)
421       add_subdirectory(javascript)
422     endif()
423   endif()
424 endif()
426 if(EXISTS ${CMAKE_CURRENT_LIST_DIR}/lua/CMakeLists.txt)
427   option(LIBA_LUA "Enable/Disable lua" 0)
428   option(LIBA_LUAJIT "Enable/Disable luajit" 0)
429   option(LIBA_WITH_LUA "Enable/Disable build with lua" 0)
431   if(LIBA_LUA OR LIBA_LUAJIT OR LIBA_WITH_LUA)
432     set(LUA_MATH_LIBRARY ${LIBA_MATH} CACHE STRING "lua math library")
433   endif()
435   if(NOT LIBA_WITH_LUA AND LIBA_LUA)
436     find_package(Lua OPTIONAL_COMPONENTS lua)
437     set(LUA_LIBRARIES lualib)
438   endif()
440   if((LIBA_LUA AND NOT LUA_FOUND AND NOT LIBA_WITH_LUA) OR LIBA_LUAJIT)
441     find_package(LuaJIT OPTIONAL_COMPONENTS luajit)
442     set(LUA_EXECUTABLE ${LUAJIT_EXECUTABLE})
443     set(LUA_LIBRARIES luajit)
444   endif()
446   if(LIBA_LUA AND LUA_FOUND)
447     add_subdirectory(lua)
448   elseif(LIBA_LUAJIT AND LUAJIT_FOUND)
449     add_subdirectory(lua)
450   elseif(LIBA_WITH_LUA)
451     add_subdirectory(lua)
452   endif()
453 endif()
455 if(EXISTS ${CMAKE_CURRENT_LIST_DIR}/python/CMakeLists.txt)
456   option(LIBA_PYTHON "Enable/Disable python" 0)
458   if(LIBA_PYTHON)
459     find_package(Python COMPONENTS Development OPTIONAL_COMPONENTS Interpreter)
460     find_package(Cython)
461   endif()
463   if(EXISTS ${CMAKE_CURRENT_LIST_DIR}/python/src/liba.c OR CYTHON_FOUND)
464     if(Python_FOUND)
465       add_subdirectory(python)
466     endif()
467   endif()
468 endif()
470 if(EXISTS ${CMAKE_CURRENT_LIST_DIR}/quickjs/CMakeLists.txt)
471   option(LIBA_QUICKJS "Enable/Disable quickjs" 0)
472   option(LIBA_WITH_QUICKJS "Enable/Disable build with quickjs" 0)
474   if(LIBA_QUICKJS OR LIBA_WITH_QUICKJS)
475     set(QUICKJS_MATH_LIBRARY ${LIBA_MATH} CACHE STRING "quickjs math library")
476   endif()
478   if(NOT LIBA_WITH_QUICKJS AND LIBA_QUICKJS)
479     find_package(QuickJS)
480   endif()
482   if(LIBA_QUICKJS AND QUICKJS_FOUND)
483     add_subdirectory(quickjs)
484   elseif(LIBA_WITH_QUICKJS)
485     add_subdirectory(quickjs)
486   endif()
487 endif()
489 if(EXISTS ${CMAKE_CURRENT_LIST_DIR}/test/CMakeLists.txt)
490   if(PROJECT_IS_TOP_LEVEL AND BUILD_TESTING)
491     add_subdirectory(test)
492   endif()
493 endif()
495 set(CPACK_SOURCE_IGNORE_FILES ${CMAKE_CURRENT_LIST_DIR}/.git)
497 if(EXISTS ${CMAKE_CURRENT_LIST_DIR}/.git AND GIT_FOUND)
498   execute_process(ERROR_QUIET
499     COMMAND ${GIT_EXECUTABLE} status -z --ignored=matching
500     OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE ignore
501   )
502   string(REPLACE "." "\\\\." ignore "${ignore}")
503   string(REPLACE "*" ".*" ignore "${ignore}")
504   string(REPLACE "?? " "!! " ignore "${ignore}")
505   string(REGEX MATCHALL "!! [^!]+" ignore "${ignore}")
506   string(REPLACE "!! " "${CMAKE_CURRENT_LIST_DIR}/" ignore "${ignore}")
507   list(APPEND CPACK_SOURCE_IGNORE_FILES ${ignore})
508 endif()
510 set(CPACK_RESOURCE_FILE_README ${CMAKE_CURRENT_LIST_DIR}/README.md)
511 set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_LIST_DIR}/LICENSE.txt)
512 include(CPack)
514 if(PROJECT_IS_TOP_LEVEL AND BUILD_TESTING)
515   find_package(ClangFormat)
516 endif()
518 if(CLANG_FORMAT_FOUND)
519   file_scaner(SOURCES EXT c h cc hh cpp hpp RECURSE include src test
520     java/src javascript/src lua/src quickjs/src
521   )
522   add_clang_format(afmt.c VERBOSE ${SOURCES})
523   add_dependencies(afmt afmt.c)
524 endif()
526 if(PROJECT_IS_TOP_LEVEL AND BUILD_TESTING)
527   find_package(Black)
528 endif()
530 if(BLACK_FOUND)
531   add_black(afmt.py ${CMAKE_CURRENT_LIST_DIR})
532   add_dependencies(afmt afmt.py)
533 endif()
535 if(NOT CMAKE_VERSION VERSION_LESS 3.9 AND DOXYGEN_FOUND)
536   # Project related configuration options
537   set(DOXYGEN_CREATE_SUBDIRS YES)
538   set(DOXYGEN_OPTIMIZE_OUTPUT_FOR_C YES)
540   # Build related configuration options
541   set(DOXYGEN_EXTRACT_STATIC YES)
543   # Configuration options related to warning and progress messages
544   set(DOXYGEN_WARN_IF_UNDOCUMENTED NO)
545   set(DOXYGEN_WARN_NO_PARAMDOC YES)
547   # Configuration options related to the input files
548   set(DOXYGEN_RECURSIVE YES)
550   # Configuration options related to source browsing
551   # Configuration options related to the alphabetical class index
552   # Configuration options related to the HTML output
553   set(DOXYGEN_GENERATE_HTML YES)
554   set(DOXYGEN_USE_MATHJAX YES)
555   set(DOXYGEN_MATHJAX_VERSION MathJax_3)
557   # Configuration options related to the LaTeX output
558   # Configuration options related to the RTF output
559   # Configuration options related to the man page output
560   # Configuration options related to the XML output
561   set(DOXYGEN_GENERATE_XML YES)
563   # Configuration options related to the DOCBOOK output
564   # Configuration options for the AutoGen Definitions output
565   # Configuration options related to Sqlite3 output
566   # Configuration options related to the Perl module output
567   # Configuration options related to the preprocessor
568   set(DOXYGEN_MACRO_EXPANSION YES)
569   set(DOXYGEN_PREDEFINED
570     "__STDC_VERSION__=201112L"
571     "__cplusplus=201103L"
572     "A_BYTE_ORDER=1234"
573     "A_SIZE_POINTER=8"
574     "A_INLINE:=inline"
575     "A_NONULL():="
576     "A_FORMAT():="
577     "A_EXTERN:="
578     "A_INTERN:="
579     "A_PUBLIC:="
580     "A_HIDDEN:="
581   )
583   file(STRINGS "${A_HAVE_H}" macros REGEX "#define[ ]+A_HAVE_.+")
585   foreach(macro ${macros})
586     string(REGEX REPLACE "#define[ ]+(.*)[ ]+(.+)" "\\1=\\2" macro "${macro}")
587     list(APPEND DOXYGEN_PREDEFINED ${macro})
588   endforeach()
590   # Configuration options related to external references
591   # Configuration options related to the dot tool
592   if(Doxygen_dot_FOUND)
593     set(DOXYGEN_HAVE_DOT YES)
594     set(DOXYGEN_INTERACTIVE_SVG YES)
595     set(DOXYGEN_DOT_IMAGE_FORMAT svg)
596     set(DOXYGEN_DOT_MULTI_TARGETS YES)
597   endif()
599   # https://www.doxygen.nl/manual/config.html
600   doxygen_add_docs(adoc.c WORKING_DIRECTORY
601     ${CMAKE_CURRENT_LIST_DIR}/include/a
602     ${CMAKE_CURRENT_LIST_DIR}/include/a
603     ${CMAKE_CURRENT_LIST_DIR}/README.md
604   )
605   add_dependencies(adoc adoc.c)
606 endif()