<commit_before>set(EXTERNAL_FLAGS "")
# Disable warnings about external code
if(MSVC)
    string(REGEX REPLACE "/Wall" "/w" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
    string(REGEX REPLACE "/Wall" "/w" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
else()
    set(EXTERNAL_FLAGS "${EXTERNAL_FLAGS} -w")
endif()

if(${BUILD_SHARED_LIBS})
    set(EXTERNAL_FLAGS "${EXTERNAL_FLAGS} -fPIC")
endif()

if(WIN32)
    set(EXTERNAL_FLAGS "${EXTERNAL_FLAGS} -DWIN32")
endif()

# ============================================================================ #

# cppformat library
include_directories(fmt)
file(GLOB FMT_SOURCES fmt/fmt/*.cc)
add_library(fmt OBJECT ${FMT_SOURCES})
set_target_properties(fmt PROPERTIES COMPILE_FLAGS ${EXTERNAL_FLAGS})

# ============================================================================ #

# TNG IO library
if(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/tng_io/CMakeLists.txt")
    message(STATUS "Unpacking TNG sources")
    execute_process(
        COMMAND ${CMAKE_COMMAND} -E tar xf ${CMAKE_CURRENT_SOURCE_DIR}/tng_io.tar.gz
        WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
    )
endif()

set(CMAKE_C_FLAGS ${EXTERNAL_FLAGS})
set(CMAKE_CXX_FLAGS ${EXTERNAL_FLAGS})

add_subdirectory(
    ${CMAKE_CURRENT_BINARY_DIR}/tng_io
    ${CMAKE_CURRENT_BINARY_DIR}/tng-build
)

# Hide TNG variables from CMake GUI
mark_as_advanced(FORCE
    TNG_BUILD_COMPRESSION_TESTS
    TNG_BUILD_EXAMPLES
    TNG_BUILD_FORTRAN
    TNG_BUILD_OWN_ZLIB
    TNG_BUILD_TEST
)

# ============================================================================ #

# VMD Molfile plugins
if(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/molfiles/LICENSE")
    message(STATUS "Unpacking molfiles sources")
    execute_process(
        COMMAND ${CMAKE_COMMAND} -E tar xf ${CMAKE_CURRENT_SOURCE_DIR}/molfiles.tar.gz
        WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}<commit_msg>Pass user-suplied flags to external dependencies<commit_after>set(EXTERNAL_FLAGS "")
# Disable warnings about external code
if(MSVC)
    string(REGEX REPLACE "/Wall" "/w" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
    string(REGEX REPLACE "/Wall" "/w" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
else()
    set(EXTERNAL_FLAGS "${EXTERNAL_FLAGS} -w")
endif()

if(${BUILD_SHARED_LIBS})
    set(EXTERNAL_FLAGS "${EXTERNAL_FLAGS} -fPIC")
endif()

if(WIN32)
    set(EXTERNAL_FLAGS "${EXTERNAL_FLAGS} -DWIN32")
endif()

# ============================================================================ #

# cppformat library
include_directories(fmt)
file(GLOB FMT_SOURCES fmt/fmt/*.cc)
add_library(fmt OBJECT ${FMT_SOURCES})
set_target_properties(fmt PROPERTIES COMPILE_FLAGS ${EXTERNAL_FLAGS})

# ============================================================================ #

# TNG IO library
if(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/tng_io/CMakeLists.txt")
    message(STATUS "Unpacking TNG sources")
    execute_process(
        COMMAND ${CMAKE_COMMAND} -E tar xf ${CMAKE_CURRENT_SOURCE_DIR}/tng_io.tar.gz
        WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
    )
endif()

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTERNAL_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTERNAL_FLAGS}")

add_subdirectory(
    ${CMAKE_CURRENT_BINARY_DIR}/tng_io
    ${CMAKE_CURRENT_BINARY_DIR}/tng-build
)

# Hide TNG variables from CMake GUI
mark_as_advanced(FORCE
    TNG_BUILD_COMPRESSION_TESTS
    TNG_BUILD_EXAMPLES
    TNG_BUILD_FORTRAN
    TNG_BUILD_OWN_ZLIB
    TNG_BUILD_TEST
)

# ============================================================================ #

# VMD Molfile plugins
if(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/molfiles/LICENSE")
    message(STATUS "Unpacking molfiles sources")
    execute_process(
        COMMAND ${CMAKE_COMMAND} -E tar xf ${CMAKE_CURRENT_SOURCE_DIR}/molfiles.tar.gz
        WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
{'fraction_non_alphanumeric': 0.22025850699024005, 'fraction_numerical': 0.0021102611448166712, 'mean_word_length': 6.195445920303605, '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': '4084753', 'n_tokens_mistral': 1366, 'n_tokens_neox': 1296, 'n_words': 216}