|
| 1 | +cmake_minimum_required(VERSION 4.3) |
| 2 | +file(STRINGS configure.ac configure_ac REGEX ^AC_INIT) |
| 3 | +string(REGEX MATCH "([0-9]+)[.][0-9]+[.][0-9]+" VER "${configure_ac}") |
| 4 | +project(libsodium VERSION ${VER} LANGUAGES C ASM) |
| 5 | +include(configure.cmake) |
| 6 | +set_property(GLOBAL PROPERTY USE_FOLDERS ON) # enables Solution Folders |
| 7 | +option(DISABLE_TESTS "Disable tests" OFF) |
| 8 | +option(ENABLE_BLOCKING_RANDOM "Enable only if /dev/urandom is totally broken on the target platform" OFF) |
| 9 | +option(ENABLE_MINIMAL "Only compile the minimum set of functions required for the high-level API" OFF) |
| 10 | +######################################## |
| 11 | +function(compareCmakeFilesys files) |
| 12 | + file(GLOB_RECURSE filesys RELATIVE ${CMAKE_CURRENT_LIST_DIR} *) |
| 13 | + file(GLOB_RECURSE ignorefiles RELATIVE ${CMAKE_CURRENT_LIST_DIR} .*.swp) |
| 14 | + if(ignorefiles) |
| 15 | + list(REMOVE_ITEM filesys ${ignorefiles}) |
| 16 | + endif() |
| 17 | + foreach(f ${filesys}) |
| 18 | + list(FIND files ${f} index) |
| 19 | + if(${index} GREATER -1) |
| 20 | + list(REMOVE_AT files ${index}) |
| 21 | + list(REMOVE_ITEM filesys ${f}) |
| 22 | + endif() |
| 23 | + endforeach() |
| 24 | + if(filesys) |
| 25 | + message(FATAL_ERROR "files not in cmake: ${filesys}") |
| 26 | + endif() |
| 27 | + foreach(f ${files}) |
| 28 | + get_filename_component(absPath ${f} ABSOLUTE) |
| 29 | + if(NOT absPath MATCHES CMAKE_CURRENT_LIST_DIR) |
| 30 | + # remove any files that aren't under CMAKE_CURRENT_LIST_DIR |
| 31 | + list(REMOVE_ITEM files ${f}) |
| 32 | + endif() |
| 33 | + endforeach() |
| 34 | + if(files) |
| 35 | + message(FATAL_ERROR "files not in repo, but in cmake: ${files}") |
| 36 | + endif() |
| 37 | +endfunction() |
| 38 | +######################################## |
| 39 | +add_subdirectory(src/libsodium) |
| 40 | +if(NOT DISABLE_TESTS) |
| 41 | + enable_testing() |
| 42 | + add_subdirectory(test) |
| 43 | +endif() |
0 commit comments