<commit_before>project(teletest)
cmake_minimum_required(VERSION 2.8)

# c++11
set(CMAKE_CXX_FLAGS "-std=c++0x ${CMAKE_CXX_FLAGS}")

# debug symbols
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wall")

# gtest
enable_testing()
find_package(GTest REQUIRED)

# libserialport
find_library(LIBSERIALPORT_LIBRARIES serialport)

#message( ${CMAKE_CURRENT_SOURCE_DIR})

include_directories(
    ${CMAKE_CURRENT_SOURCE_DIR}/include
    ${GTEST_INCLUDE_DIRS})

set(SOURCES
    src/main.cpp
    src/SerialInterface.cpp
    src/TeleAssertion.cpp
    src/FunctionInfo.cpp
)

add_executable(${PROJECT_NAME} ${SOURCES})
target_link_libraries(${PROJECT_NAME} ${GTEST_BOTH_LIBRARIES} serialport)

#TODO add if case
add_executable(uut_example misc/uut_example.c)
target_link_libraries(uut_example serialport wiringPi)

# testing
#add_test(AllTestsInFoo foo)

add_executable(crc_example misc/crc_example.c)
#target_link_libraries(crc_example)<commit_msg>some cmake changes, need some more fixes<commit_after>project(teletest)
cmake_minimum_required(VERSION 2.8)

# c++11
set(CMAKE_CXX_FLAGS "-std=c++0x ${CMAKE_CXX_FLAGS}")

# debug symbols
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wall")

# externals
set(GTEST NO)
set(DOWNLOAD_EXTERNALS NO)

enable_testing()
include(ExternalProject)
set(EXTERNAL_INSTALL_LOCATION ${CMAKE_BINARY_DIR}/external)

# gtest
if (GTEST)
ExternalProject_Add(googletest
    GIT_REPOSITORY https://github.com/google/googletest
    CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${EXTERNAL_INSTALL_LOCATION}
)
endif (GTEST)

include_directories(${EXTERNAL_INSTALL_LOCATION}/include)
link_directories(${EXTERNAL_INSTALL_LOCATION}/lib)


# libserialport
# TODO FIXMEload externally
IF (${DOWNLOAD_EXTERNALS})
    ExternalProject_Add(serialport_tmp
        GIT_REPOSITORY git://sigrok.org/libserialport
        GIT_TAG master
        UPDATE_COMMAND ../${EP_BASE}/serialport_tmp/autogen.sh
        CONFIGURE_COMMAND ../${EP_BASE}/serialport_tmp/configure --prefix=${EXTERNAL_INSTALL_LOCATION}
        BUILD_COMMAND make
        INSTALL_COMMAND make install)


    add_library(serialport SHARED IMPORTED)
    add_dependencies(serialport serialport_tmp)

ELSE (${DOWNLOAD_EXTERNALS})
    find_library(LIBSERIALPORT_LIBRARIES serialport)
ENDIF (${DOWNLOAD_EXTERNALS})

#find_library(serialport)

# inih
ExternalProject_Add(inih_tmp
    GIT_REPOSITORY https://github.com/benhoyt/inih.git
    GIT_TAG master
    UPDATE_COMMAND ""
    CONFIGURE_COMMAND ""
    BUILD_COMMAND ""
    INSTALL_COMMAND "")

ExternalProject_Get_Property(inih_tmp SOURCE_DIR)
message(${SOURCE_DIR})
# TODO FIXME this is not working properly
include_directories(${SOURCE_DIR}/cpp)
add_library(inih ${SOURCE_DIR}/cpp/INIReader.cpp)

#message( ${CMAKE_CURRENT_SOURCE_DIR})

include_directories(
    ${CMAKE_CURRENT_SOURCE_DIR}/include
    ${GTEST_INCLUDE_DIRS})

set(SOURCES
    src/main.cpp
    src/SerialInterface.cpp
    src/TeleAssertion.cpp
)

add_executable(${PROJECT_NAME} ${SOURCES})
target_link_libraries(${PROJECT_NAME} ${GTEST_BOTH_LIBRARIES} serialport inih)

#TODO add if case
#add_executable(uut_example misc/uut_example.c)
#target_link_libraries(uut_example serialport wiringPi)

# testing
#add_test(AllTestsInFoo foo)

add_executable(crc_example misc/crc_example.c)
#target_link_libraries(crc_example)
{'fraction_non_alphanumeric': 0.10114001753873136, 'fraction_numerical': 0.0029231218941829875, 'mean_word_length': 6.777272727272727, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '1145995', 'n_tokens_mistral': 1319, 'n_tokens_neox': 1242, 'n_words': 179}