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

set(VERSION_MAJOR 0)
set(VERSION_MINOR 1)
set(VERSION_PATCH 0)

include("cmake/ColorMessage.cmake")
SET(BUILD_RTOSC_EXAMPLES FALSE CACHE BOOL
    "Build RTOSC Example Programs")

if(CMAKE_SYSTEM_NAME MATCHES "Linux")
    include(GNUInstallDirs)
endif()


include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
set(CXX11_FLAG "-std=c++11")
set(PIC_FLAG "-fPIC")
set(OPT_FLAG "-O2")
if(CMAKE_BUILD_TYPE STREQUAL Debug)
    set(OPT_FLAG "")
endif()
if(WIN32)
    #code is position-independent by default on Windows
    set(PIC_FLAG "")
endif()
if(NOT WIN32 OR CMAKE_COMPILER_IS_GNUCC)
    set(CMAKE_C_FLAGS   "${OPT_FLAG} ${CMAKE_C_FLAGS} -fPIC -std=c99   -Wall -Wextra")
    set(CPP_FLAGS       "${OPT_FLAG} ${FPIC_FLAG} -Wall -Wextra -Wno-unused-parameter")
endif()

if(CMAKE_COMPILER_IS_GNUCC)
    execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion
        OUTPUT_VARIABLE GCC_VERSION)
    if (GCC_VERSION VERSION_GREATER 4.7 OR GCC_VERSION VERSION_EQUAL
            4.7)
        message(STATUS "Found GCC Version >= 4.7")
    else()
        message(WARNING "GCC Version '${GCC_VERSION}' Is Quite Old, Please Consider Upgrading")
        set(CXX11_FLAG "-std=c++0x")
    endif()
endif()

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CPP_FLAGS} ${CXX11_FLAG}")

add_library(rtosc STATIC src/rtosc.c src/dispatch.c)
add_library(rtosc-cpp STATIC src/cpp/ports.cpp src/cpp/miditable.cpp
    src/cpp/midimapper.cpp
    src/cpp/thread-link.cpp
    src/cpp/undo-history.cpp
    src/cpp/subtree-serialize.cpp)
target_link_libraries(rtosc-cpp rtosc)

# Example Code
find_package(FLTK)
find_package(PkgConfig)
if(PKG_CONFIG_FOUND)
    pkg_check_modules(NTK ntk)
    pkg_check_modules(JACK jack)
    pkg_check_modules(LIBLO liblo>=0.28)
endif()

if(FLTK_FOUND)
    execute_process(COMMAND fltk-config --api-version
        OUTPUT_VARIABLE FLTK_VERSION
        OUTPUT_STRIP_TRAILING_WHITESPACE)
endif(FLTK_FOUND)

if(NTK_FOUND)
    #Default to NTK, as everything looks better there
    set(GUI_FOUND TRUE)
    set(GUI_LIBRARIES ${NTK_LDFLAGS})
    include_directories(${NTK_INCLUDE_DIRS})
elseif(FLTK_FOUND AND (FLTK_VERSION STREQUAL "1.3"))
    set(GUI_FOUND TRUE)
    set(GUI_LIBRARIES ${FLTK_LIBRARIES})
else()
    set(GUI_FOUND FALSE)
endif()


if(JACK_FOUND AND GUI_FOUND AND BUILD_RTOSC_EXAMPLES)
    add_executable(simple-example example/simple/ui.cpp example/simple/synth.cpp)
    target_link_libraries(simple-example m rtosc ${GUI_LIBRARIES}
        ${JACK_LDFLAGS})

    add_executable(complex-example example/complex/audio.cpp
        example/complex/synth.cpp example/complex/window.cpp
        example/complex/Fl_Osc_Dial.cpp example/complex/Fl_Osc_Slider.cpp
        example/complex/Fl_Osc_Button.cpp)
    target_link_libraries(complex-example m rtosc rtosc-cpp ${GUI_LIBRARIES}
        ${JACK_LDFLAGS})
    #TODO add complex example (ie klatter (an unplublished project for those reading))
endif()

if(BUILD_RTOSC_EXAMPLES)
    add_executable(modular-example
        example/modular/Echo.cpp
        example/modular/EffectMgr.cpp
        example/modular/LFO.cpp
        example/modular/main.cpp
        example/modular/Oscil.cpp
        example/modular/Synth.cpp
        example/modular/util.cpp
        )
    target_link_libraries(modular-example m rtosc rtosc-cpp)
endif(BUILD_RTOSC_EXAMPLES)


# Testing code
enable_testing()
macro(maketest fname)
    add_executable(${fname} test/${fname}.c)
    add_test(${fname} ${fname})
    target_link_libraries(${fname} rtosc)
endmacro(maketest)

macro(maketestcpp fname)
    add_executable(${fname} test/${fname}.cpp)
    add_test(${fname} ${fname})
    target_link_libraries(${fname} rtosc-cpp rtosc)
endmacro(maketestcpp)

maketest(osc-spec)
maketest(simple-messages)
maketest(null-messages)
maketest(bundles)
maketest(patterns)
maketest(nested-bundles)
maketest(fat-message)
maketest(empty-strings)
maketest(message-alignment)
maketest(test-arg-iter)
if(LIBLO_FOUND)
    include_directories(${LIBLO_INCLUDE_DIRS})
    maketest(liblo)
    target_link_libraries(liblo ${LIBLO_LDFLAGS})
endif()

if(JACK_FOUND)
    include_directories(${JACK_INCLUDE_DIRS})
endif()

maketestcpp(metadata)
maketestcpp(headerlib)
maketestcpp(test-walker)
maketestcpp(performance)

maketestcpp(undo-test)
maketestcpp(serializer)
maketestcpp(sugar)
maketestcpp(typed-template-test)

maketestcpp(path-collapse)

# Documentation
find_package(Doxygen)
SET(Documentation FALSE CACHE BOOL "Enable building documentation")
<commit_msg>Disable Typed Messages Under Old GCC<commit_after>cmake_minimum_required(VERSION 2.8)
project(RTOSC)

set(VERSION_MAJOR 0)
set(VERSION_MINOR 1)
set(VERSION_PATCH 0)

include("cmake/ColorMessage.cmake")
SET(BUILD_RTOSC_EXAMPLES FALSE CACHE BOOL
    "Build RTOSC Example Programs")

if(CMAKE_SYSTEM_NAME MATCHES "Linux")
    include(GNUInstallDirs)
endif()


include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
set(CXX11_FLAG "-std=c++11")
set(PIC_FLAG "-fPIC")
set(OPT_FLAG "-O2")
if(CMAKE_BUILD_TYPE STREQUAL Debug)
    set(OPT_FLAG "")
endif()
if(WIN32)
    #code is position-independent by default on Windows
    set(PIC_FLAG "")
endif()
if(NOT WIN32 OR CMAKE_COMPILER_IS_GNUCC)
    set(CMAKE_C_FLAGS   "${OPT_FLAG} ${CMAKE_C_FLAGS} -fPIC -std=c99   -Wall -Wextra")
    set(CPP_FLAGS       "${OPT_FLAG} ${FPIC_FLAG} -Wall -Wextra -Wno-unused-parameter")
endif()

if(CMAKE_COMPILER_IS_GNUCC)
    execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion
        OUTPUT_VARIABLE GCC_VERSION)
    if (GCC_VERSION VERSION_GREATER 4.7 OR GCC_VERSION VERSION_EQUAL
            4.7)
        message(STATUS "Found GCC Version >= 4.7")
    else()
        message(WARNING "GCC Version '${GCC_VERSION}' Is Quite Old, Please Consider Upgrading")
        set(CXX11_FLAG "-std=c++0x")
    endif()
endif()

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CPP_FLAGS} ${CXX11_FLAG}")

add_library(rtosc STATIC src/rtosc.c src/dispatch.c)
add_library(rtosc-cpp STATIC src/cpp/ports.cpp src/cpp/miditable.cpp
    src/cpp/midimapper.cpp
    src/cpp/thread-link.cpp
    src/cpp/undo-history.cpp
    src/cpp/subtree-serialize.cpp)
target_link_libraries(rtosc-cpp rtosc)

# Example Code
find_package(FLTK)
find_package(PkgConfig)
if(PKG_CONFIG_FOUND)
    pkg_check_modules(NTK ntk)
    pkg_check_modules(JACK jack)
    pkg_check_modules(LIBLO liblo>=0.28)
endif()

if(FLTK_FOUND)
    execute_process(COMMAND fltk-config --api-version
        OUTPUT_VARIABLE FLTK_VERSION
        OUTPUT_STRIP_TRAILING_WHITESPACE)
endif(FLTK_FOUND)

if(NTK_FOUND)
    #Default to NTK, as everything looks better there
    set(GUI_FOUND TRUE)
    set(GUI_LIBRARIES ${NTK_LDFLAGS})
    include_directories(${NTK_INCLUDE_DIRS})
elseif(FLTK_FOUND AND (FLTK_VERSION STREQUAL "1.3"))
    set(GUI_FOUND TRUE)
    set(GUI_LIBRARIES ${FLTK_LIBRARIES})
else()
    set(GUI_FOUND FALSE)
endif()


if(JACK_FOUND AND GUI_FOUND AND BUILD_RTOSC_EXAMPLES)
    add_executable(simple-example example/simple/ui.cpp example/simple/synth.cpp)
    target_link_libraries(simple-example m rtosc ${GUI_LIBRARIES}
        ${JACK_LDFLAGS})

    add_executable(complex-example example/complex/audio.cpp
        example/complex/synth.cpp example/complex/window.cpp
        example/complex/Fl_Osc_Dial.cpp example/complex/Fl_Osc_Slider.cpp
        example/complex/Fl_Osc_Button.cpp)
    target_link_libraries(complex-example m rtosc rtosc-cpp ${GUI_LIBRARIES}
        ${JACK_LDFLAGS})
    #TODO add complex example (ie klatter (an unplublished project for those reading))
endif()

if(BUILD_RTOSC_EXAMPLES)
    add_executable(modular-example
        example/modular/Echo.cpp
        example/modular/EffectMgr.cpp
        example/modular/LFO.cpp
        example/modular/main.cpp
        example/modular/Oscil.cpp
        example/modular/Synth.cpp
        example/modular/util.cpp
        )
    target_link_libraries(modular-example m rtosc rtosc-cpp)
endif(BUILD_RTOSC_EXAMPLES)


# Testing code
enable_testing()
macro(maketest fname)
    add_executable(${fname} test/${fname}.c)
    add_test(${fname} ${fname})
    target_link_libraries(${fname} rtosc)
endmacro(maketest)

macro(maketestcpp fname)
    add_executable(${fname} test/${fname}.cpp)
    add_test(${fname} ${fname})
    target_link_libraries(${fname} rtosc-cpp rtosc)
endmacro(maketestcpp)

maketest(osc-spec)
maketest(simple-messages)
maketest(null-messages)
maketest(bundles)
maketest(patterns)
maketest(nested-bundles)
maketest(fat-message)
maketest(empty-strings)
maketest(message-alignment)
maketest(test-arg-iter)
if(LIBLO_FOUND)
    include_directories(${LIBLO_INCLUDE_DIRS})
    maketest(liblo)
    target_link_libraries(liblo ${LIBLO_LDFLAGS})
endif()

if(JACK_FOUND)
    include_directories(${JACK_INCLUDE_DIRS})
endif()

maketestcpp(metadata)
maketestcpp(headerlib)
maketestcpp(test-walker)
maketestcpp(performance)

maketestcpp(undo-test)
maketestcpp(serializer)
maketestcpp(sugar)
if(CXX11_FLAG STREQUAL "-std=c++11")
    maketestcpp(typed-template-test)
endif()

maketestcpp(path-collapse)

# Documentation
find_package(Doxygen)
SET(Documentation FALSE CACHE BOOL "Enable building documentation")

{'fraction_non_alphanumeric': 0.1091387245233399, 'fraction_numerical': 0.00745123822046899, 'mean_word_length': 4.8096753660089115, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '452593', 'n_tokens_mistral': 3616, 'n_tokens_neox': 3410, 'n_words': 557}