file(GLOB sources "src/*.cpp" "src/*.c" "src/*.hpp" "src/*.h")
# Remove "app" sources from list
list(REMOVE_ITEM sources
    "${CMAKE_CURRENT_SOURCE_DIR}/src/cadical.cpp"
    "${CMAKE_CURRENT_SOURCE_DIR}/src/mobical.cpp"
)

add_library(cadical ${sources})

# Pass -DNBUILD to disable including the version information, which is not
# needed since cbmc doesn't run the cadical binary
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
    target_compile_options(
        cadical
        PRIVATE
        -DNBUILD -DNFLEXIBLE -DNDEBUG
    )
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR
       "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
    if (CMAKE_HOST_SYSTEM_NAME STREQUAL Darwin)
        target_compile_options(
            cadical
            PRIVATE
            -DNBUILD -DNFLEXIBLE -DNDEBUG -DNCLOSEFROM
        )
    else()
        target_compile_options(
            cadical
            PRIVATE
            -DNBUILD -DNFLEXIBLE -DNDEBUG
        )
    endif()
else()
    target_compile_options(cadical PRIVATE -DNBUILD -DNFLEXIBLE -DNDEBUG)
endif()

set_target_properties(
    cadical
    PROPERTIES
    CXX_STANDARD 17
    CXX_STANDARD_REQUIRED true
    CXX_EXTENSIONS OFF
    XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "Developer ID Application: Daniel Kroening"
)

target_include_directories(cadical
    PUBLIC
    ${CMAKE_CURRENT_SOURCE_DIR}/src
)

target_link_libraries(cadical util)
