<commit_before>cmake_minimum_required(VERSION 3.2)
project(reroaring)

OPTION(COMPILE_MODE "Compile mode" "lib")

set(CMAKE_VERBOSE_MAKEFILE on)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -Wall -Werror")
set(SRC_PATH ${CMAKE_CURRENT_SOURCE_DIR}/src)
set(DEPS_PATH ${CMAKE_CURRENT_SOURCE_DIR}/deps)
set(TEST_PATH ${CMAKE_CURRENT_SOURCE_DIR}/tests)
set(CROARING_PATH ${DEPS_PATH}/CRoaring)
set(CROARING_BUILD_PATH ${DEPS_PATH}/CRoaring/build/src)


set(CMAKE_POSITION_INDEPENDENT_CODE ON)
include_directories(${CROARING_PATH})

link_directories(${CROARING_BUILD_PATH})
set(SOURCE_FILES ${SRC_PATH}/reroaring.c
        ${SRC_PATH}/type.c
        ${SRC_PATH}/data_structure.c)
add_library(reroaring SHARED ${SOURCE_FILES})
target_link_libraries(reroaring roaring)

if (COMPILE_MODE STREQUAL "test")
    set(CMAKE_C_FLAGS_RELEASE "") # removes -NDEBUG

    include_directories(${SRC_PATH})
    enable_testing()
    set(TEST_FILES
            ${SRC_PATH}/data_structure.c
            ${TEST_PATH}/main.c)
    link_directories(${CROARING_BUILD_PATH})
    add_executable(test_reroaring ${TEST_FILES})
    target_link_libraries(test_reroaring roaring)
    add_test(NAME basic_tests COMMAND test_reroaring)
endif ()<commit_msg>Refactor CMakeLists to use test/lib build<commit_after>cmake_minimum_required(VERSION 3.2)
project(reroaring)

set(CMAKE_VERBOSE_MAKEFILE on)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -Wall -Werror")
set(SRC_PATH ${CMAKE_CURRENT_SOURCE_DIR}/src)
set(DEPS_PATH ${CMAKE_CURRENT_SOURCE_DIR}/deps)
set(TEST_PATH ${CMAKE_CURRENT_SOURCE_DIR}/tests)
set(CROARING_PATH ${DEPS_PATH}/CRoaring)
set(CROARING_BUILD_PATH ${DEPS_PATH}/CRoaring/build/src)

link_directories(${CROARING_BUILD_PATH})
include_directories(${CROARING_PATH})

if (COMPILE_MODE STREQUAL "test")
    set(CMAKE_C_FLAGS_RELEASE "") # removes -NDEBUG

    include_directories(${SRC_PATH})
    enable_testing()
    set(TEST_FILES
            ${SRC_PATH}/data_structure.c
            ${TEST_PATH}/main.c)

    add_executable(test_reroaring ${TEST_FILES})
    target_link_libraries(test_reroaring roaring)
    add_test(NAME basic_tests COMMAND test_reroaring)
else ()
    set(CMAKE_POSITION_INDEPENDENT_CODE ON)

    set(SOURCE_FILES ${SRC_PATH}/reroaring.c
            ${SRC_PATH}/type.c
            ${SRC_PATH}/data_structure.c)
    add_library(reroaring SHARED ${SOURCE_FILES})
    target_link_libraries(reroaring roaring)
endif ()
{'fraction_non_alphanumeric': 0.11267605633802817, 'fraction_numerical': 0.0033140016570008283, 'mean_word_length': 5.959654178674351, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '566103', 'n_tokens_mistral': 942, 'n_tokens_neox': 887, 'n_words': 119}