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


if (UNIX)
    find_path (BOOST_INCLUDEDIR boost/lexical_cast.hpp /usr/include)
else ()
    find_path (BOOST_INCLUDEDIR boost/lexical_cast.hpp c:/yborm/include)
endif ()

# find boost + libxml2

if (MSVC)
    set (Boost_USE_STATIC_LIBS ON)
else ()
    set (Boost_USE_STATIC_LIBS OFF)
endif ()
set (Boost_USE_MULTITHREADED ON)
set (Boost_NO_SYSTEM_PATHS ON)
#set (Boost_DEBUG ON)
set (Boost_ADDITIONAL_VERSIONS "1.33.1" "1.38" "1.30.0" "1.46.1")
if (UNIX)
    set (BOOST_LIBRARYDIR "/usr/lib")
else ()
    set (BOOST_LIBRARYDIR "c:/yborm/lib")
endif ()

find_package (Boost 1.33.1 COMPONENTS thread date_time)
if ((NOT Boost_DATE_TIME_LIBRARY) OR (NOT Boost_THREAD_LIBRARY))
    message (FATAL_ERROR "Boost not found")
endif ()

# find includes

if (UNIX)
    find_path (ICONV_INCLUDES iconv.h /usr/include)
else ()
    find_path (ICONV_INCLUDES iconv.h c:/yborm/include)
endif ()

if (UNIX)
    find_path (LIBXML2_INCLUDES libxml/xmlwriter.h /usr/include/libxml2)
else ()
    find_path (LIBXML2_INCLUDES libxml/xmlwriter.h c:/yborm/include)
endif ()

# find libs

if (MSVC)
    find_library (ICONV_LIBS iconv c:/yborm/lib)
elseif (BORLAND)
    find_library (ICONV_LIBS iconvomf c:/yborm/lib)
endif ()

if (UNIX)
    find_library (LIBXML2_LIBS xml2)
elseif (MSVC)
    find_library (LIBXML2_LIBS libxml2 c:/yborm/lib)
elseif (BORLAND)
    find_library (LIBXML2_LIBS libxml2omf c:/yborm/lib)
else ()
    find_library (LIBXML2_LIBS libxml2 c:/yborm/bin)
endif ()

if (UNIX)
    find_library (ODBC_LIBS odbc)
elseif (BORLAND)
    find_library (ODBC_LIBS odbc32 c:/Borland/BCC55/Lib/PSDK)
elseif (MSVC)
    find_library (ODBC_LIBS odbc32)
elseif (MINGW)
    set (ODBC_LIBS -lodbc32 CACHE STRING "odbc32 lib" FORCE)
endif ()

if (SQLITE3_INCLUDEDIR)
    find_path (SQLITE3_INCLUDEDIR sqlite3.h ${SQLITE3_INCLUDEDIR})
elseif (UNIX)
    find_path (SQLITE3_INCLUDEDIR sqlite3.h /usr/include)
else ()
    find_path (SQLITE3_INCLUDEDIR sqlite3.h c:/yborm/include)
endif ()

if (SQLITE3_LIBDIR)
    find_library (SQLITE3_LIBS sqlite3 ${SQLITE3_LIBDIR})
elseif (UNIX)
    find_library (SQLITE3_LIBS sqlite3)
else ()
    find_library (SQLITE3_LIBS sqlite3 c:/yborm/lib c:/yborm/bin)
endif ()

if (SQLITE3_INCLUDEDIR AND SQLITE3_LIBS)
    add_definitions (-D YB_USE_SQLITE3)
    set (USE_SQLITE3 ON)
else ()
    set (SQLITE3_LIBS "")
    set (SQLITE3_INCLUDEDIR "")
    set (USE_SQLITE3 OFF)
endif ()

if (BOOST_INCLUDEDIR AND (NOT BORLAND))
    add_definitions (-D YB_USE_TUPLE)
endif()

function (check_yborm_root YBORM_ROOT)
    if (EXISTS ${YBORM_ROOT})
        find_path (YBORM_INCLUDES orm/SqlDriver.h ${YBORM_ROOT}/include/yb)
        find_library (YBUTIL_LIB ybutil ${YBORM_ROOT}/lib)
        find_library (YBORM_LIB yborm ${YBORM_ROOT}/lib)
        if (YBORM_INCLUDES AND YBUTIL_LIB AND YBORM_LIB)
	    message (STATUS "YB.ORM found: ${YBORM_ROOT}")
        endif ()
    endif ()
endfunction ()

if (((NOT YBORM_INCLUDES) OR (NOT YBUTIL_LIB) OR (NOT YBORM_LIB))
        AND YBORM_ROOT)
    check_yborm_root (${YBORM_ROOT})
endif ()
if ((NOT YBORM_INCLUDES) OR (NOT YBUTIL_LIB) OR (NOT YBORM_LIB))
    if (UNIX)
        check_yborm_root (/usr/local)
    else ()
        check_yborm_root (c:/yborm)
    endif ()
endif ()
if ((NOT YBORM_INCLUDES) OR (NOT YBUTIL_LIB) OR (NOT YBORM_LIB))
    message(SEND_ERROR "YB.ORM not found")
endif ()

if (YBUTIL_LIB)
    find_library (YBUTIL_LIB ${YBUTIL_LIB})
endif ()

if (YBORM_LIB)
    find_library (YBORM_LIB ${YBORM_LIB})
endif ()

add_subdirectory (domain)


include_directories (
    ${ICONV_INCLUDES}
    ${LIBXML2_INCLUDES}
	${BOOST_INCLUDEDIR}
    ${YBORM_INCLUDES}
    ${CMAKE_CURRENT_BINARY_DIR})

add_executable (tut1 tut1.cpp
    ${CMAKE_CURRENT_BINARY_DIR}/domain/Client.cpp
    ${CMAKE_CURRENT_BINARY_DIR}/domain/Order.cpp)

add_executable (tut2 tut2.cpp
    ${CMAKE_CURRENT_BINARY_DIR}/domain/Client.cpp
    ${CMAKE_CURRENT_BINARY_DIR}/domain/Order.cpp)

set_source_files_properties (
    ${CMAKE_CURRENT_BINARY_DIR}/domain/Client.cpp
    ${CMAKE_CURRENT_BINARY_DIR}/domain/Order.cpp
    ${CMAKE_CURRENT_BINARY_DIR}/tut1.sql
    ${CMAKE_CURRENT_BINARY_DIR}/tut2.sql
    PROPERTIES GENERATED 1)

add_custom_command (
    OUTPUT tut1.sql
    COMMAND ${YBORM_ROOT}/bin/yborm_gen --ddl ${PROJECT_SOURCE_DIR}/tut1.xml MYSQL ${CMAKE_CURRENT_BINARY_DIR}/tut1.sql
    DEPENDS ${PROJECT_SOURCE_DIR}/tut1.xml
)

add_custom_target (gen_sql_tut1 DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/tut1.sql)

add_dependencies (tut1 gen_cpp_tut1)
add_dependencies (tut1 gen_sql_tut1)
add_dependencies (tut2 gen_cpp_tut1)
add_dependencies (tut2 gen_sql_tut1)

target_link_libraries (tut1 ${YBORM_LIB} ${YBUTIL_LIB} ${LIBXML2_LIBS}
    ${Boost_DATE_TIME_LIBRARY} ${Boost_THREAD_LIBRARY} ${ODBC_LIBS}
    ${SQLITE3_LIBS})

target_link_libraries (tut2 ${YBORM_LIB} ${YBUTIL_LIB} ${LIBXML2_LIBS}
    ${Boost_DATE_TIME_LIBRARY} ${Boost_THREAD_LIBRARY} ${ODBC_LIBS}
    ${SQLITE3_LIBS})

install (TARGETS tut1 tut2 DESTINATION examples)
install (FILES tut1.xml ${CMAKE_CURRENT_BINARY_DIR}/tut1.sql DESTINATION examples)
<commit_msg>Add tut3.cpp to CMake script<commit_after>
cmake_minimum_required (VERSION 2.8)
project (tutorial)


if (UNIX)
    find_path (BOOST_INCLUDEDIR boost/lexical_cast.hpp /usr/include)
else ()
    find_path (BOOST_INCLUDEDIR boost/lexical_cast.hpp c:/yborm/include)
endif ()

# find boost + libxml2

if (MSVC)
    set (Boost_USE_STATIC_LIBS ON)
else ()
    set (Boost_USE_STATIC_LIBS OFF)
endif ()
set (Boost_USE_MULTITHREADED ON)
set (Boost_NO_SYSTEM_PATHS ON)
#set (Boost_DEBUG ON)
set (Boost_ADDITIONAL_VERSIONS "1.33.1" "1.38" "1.30.0" "1.46.1")
if (UNIX)
    set (BOOST_LIBRARYDIR "/usr/lib")
else ()
    set (BOOST_LIBRARYDIR "c:/yborm/lib")
endif ()

find_package (Boost 1.33.1 COMPONENTS thread date_time)
if ((NOT Boost_DATE_TIME_LIBRARY) OR (NOT Boost_THREAD_LIBRARY))
    message (FATAL_ERROR "Boost not found")
endif ()

# find includes

if (UNIX)
    find_path (ICONV_INCLUDES iconv.h /usr/include)
else ()
    find_path (ICONV_INCLUDES iconv.h c:/yborm/include)
endif ()

if (UNIX)
    find_path (LIBXML2_INCLUDES libxml/xmlwriter.h /usr/include/libxml2)
else ()
    find_path (LIBXML2_INCLUDES libxml/xmlwriter.h c:/yborm/include)
endif ()

# find libs

if (MSVC)
    find_library (ICONV_LIBS iconv c:/yborm/lib)
elseif (BORLAND)
    find_library (ICONV_LIBS iconvomf c:/yborm/lib)
endif ()

if (UNIX)
    find_library (LIBXML2_LIBS xml2)
elseif (MSVC)
    find_library (LIBXML2_LIBS libxml2 c:/yborm/lib)
elseif (BORLAND)
    find_library (LIBXML2_LIBS libxml2omf c:/yborm/lib)
else ()
    find_library (LIBXML2_LIBS libxml2 c:/yborm/bin)
endif ()

if (UNIX)
    find_library (ODBC_LIBS odbc)
elseif (BORLAND)
    find_library (ODBC_LIBS odbc32 c:/Borland/BCC55/Lib/PSDK)
elseif (MSVC)
    find_library (ODBC_LIBS odbc32)
elseif (MINGW)
    set (ODBC_LIBS -lodbc32 CACHE STRING "odbc32 lib" FORCE)
endif ()

if (SQLITE3_INCLUDEDIR)
    find_path (SQLITE3_INCLUDEDIR sqlite3.h ${SQLITE3_INCLUDEDIR})
elseif (UNIX)
    find_path (SQLITE3_INCLUDEDIR sqlite3.h /usr/include)
else ()
    find_path (SQLITE3_INCLUDEDIR sqlite3.h c:/yborm/include)
endif ()

if (SQLITE3_LIBDIR)
    find_library (SQLITE3_LIBS sqlite3 ${SQLITE3_LIBDIR})
elseif (UNIX)
    find_library (SQLITE3_LIBS sqlite3)
else ()
    find_library (SQLITE3_LIBS sqlite3 c:/yborm/lib c:/yborm/bin)
endif ()

if (SQLITE3_INCLUDEDIR AND SQLITE3_LIBS)
    add_definitions (-D YB_USE_SQLITE3)
    set (USE_SQLITE3 ON)
else ()
    set (SQLITE3_LIBS "")
    set (SQLITE3_INCLUDEDIR "")
    set (USE_SQLITE3 OFF)
endif ()

if (BOOST_INCLUDEDIR AND (NOT BORLAND))
    add_definitions (-D YB_USE_TUPLE)
endif()

function (check_yborm_root YBORM_ROOT)
    if (EXISTS ${YBORM_ROOT})
        find_path (YBORM_INCLUDES orm/SqlDriver.h ${YBORM_ROOT}/include/yb)
        find_library (YBUTIL_LIB ybutil ${YBORM_ROOT}/lib)
        find_library (YBORM_LIB yborm ${YBORM_ROOT}/lib)
        if (YBORM_INCLUDES AND YBUTIL_LIB AND YBORM_LIB)
	    message (STATUS "YB.ORM found: ${YBORM_ROOT}")
        endif ()
    endif ()
endfunction ()

if (((NOT YBORM_INCLUDES) OR (NOT YBUTIL_LIB) OR (NOT YBORM_LIB))
        AND YBORM_ROOT)
    check_yborm_root (${YBORM_ROOT})
endif ()
if ((NOT YBORM_INCLUDES) OR (NOT YBUTIL_LIB) OR (NOT YBORM_LIB))
    if (UNIX)
        check_yborm_root (/usr/local)
    else ()
        check_yborm_root (c:/yborm)
    endif ()
endif ()
if ((NOT YBORM_INCLUDES) OR (NOT YBUTIL_LIB) OR (NOT YBORM_LIB))
    message(SEND_ERROR "YB.ORM not found")
endif ()

if (YBUTIL_LIB)
    find_library (YBUTIL_LIB ${YBUTIL_LIB})
endif ()

if (YBORM_LIB)
    find_library (YBORM_LIB ${YBORM_LIB})
endif ()

add_subdirectory (domain)


include_directories (
    ${ICONV_INCLUDES}
    ${LIBXML2_INCLUDES}
	${BOOST_INCLUDEDIR}
    ${YBORM_INCLUDES}
    ${CMAKE_CURRENT_BINARY_DIR})

add_executable (tut1 tut1.cpp
    ${CMAKE_CURRENT_BINARY_DIR}/domain/Client.cpp
    ${CMAKE_CURRENT_BINARY_DIR}/domain/Order.cpp)

add_executable (tut2 tut2.cpp
    ${CMAKE_CURRENT_BINARY_DIR}/domain/Client.cpp
    ${CMAKE_CURRENT_BINARY_DIR}/domain/Order.cpp)

add_executable (tut3 tut3.cpp
    ${CMAKE_CURRENT_BINARY_DIR}/domain/Client.cpp
    ${CMAKE_CURRENT_BINARY_DIR}/domain/Order.cpp)

set_source_files_properties (
    ${CMAKE_CURRENT_BINARY_DIR}/domain/Client.cpp
    ${CMAKE_CURRENT_BINARY_DIR}/domain/Order.cpp
    ${CMAKE_CURRENT_BINARY_DIR}/tut1.sql
    ${CMAKE_CURRENT_BINARY_DIR}/tut2.sql
    PROPERTIES GENERATED 1)

add_custom_command (
    OUTPUT tut1.sql
    COMMAND ${YBORM_ROOT}/bin/yborm_gen --ddl ${PROJECT_SOURCE_DIR}/tut1.xml MYSQL ${CMAKE_CURRENT_BINARY_DIR}/tut1.sql
    DEPENDS ${PROJECT_SOURCE_DIR}/tut1.xml
)

add_custom_target (gen_sql_tut1 DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/tut1.sql)

add_dependencies (tut1 gen_cpp_tut1)
add_dependencies (tut1 gen_sql_tut1)
add_dependencies (tut2 gen_cpp_tut1)
add_dependencies (tut2 gen_sql_tut1)
add_dependencies (tut3 gen_cpp_tut1)
add_dependencies (tut3 gen_sql_tut1)

target_link_libraries (tut1 ${YBORM_LIB} ${YBUTIL_LIB} ${LIBXML2_LIBS}
    ${Boost_DATE_TIME_LIBRARY} ${Boost_THREAD_LIBRARY} ${ODBC_LIBS}
    ${SQLITE3_LIBS})

target_link_libraries (tut2 ${YBORM_LIB} ${YBUTIL_LIB} ${LIBXML2_LIBS}
    ${Boost_DATE_TIME_LIBRARY} ${Boost_THREAD_LIBRARY} ${ODBC_LIBS}
    ${SQLITE3_LIBS})

target_link_libraries (tut3 ${YBORM_LIB} ${YBUTIL_LIB} ${LIBXML2_LIBS}
    ${Boost_DATE_TIME_LIBRARY} ${Boost_THREAD_LIBRARY} ${ODBC_LIBS}
    ${SQLITE3_LIBS})

install (TARGETS tut1 tut2 tut3 DESTINATION examples)
install (FILES tut1.xml ${CMAKE_CURRENT_BINARY_DIR}/tut1.sql DESTINATION examples)

{'fraction_non_alphanumeric': 0.11179129779619514, 'fraction_numerical': 0.019495196835562254, 'mean_word_length': 4.678609625668449, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 26}, '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': '4298089', 'n_tokens_mistral': 4639, 'n_tokens_neox': 4446, 'n_words': 829}