<commit_before>cmake_minimum_required(VERSION 2.8.8)
# set(CMAKE_VERBOSE_MAKEFILE on )

project(open62541 C)
set(open62541_VERSION_MAJOR 0)
set(open62541_VERSION_MINOR 0)
set(open62541_VERSION_PATCH 0)

set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")

# Set default build type.
if (NOT CMAKE_BUILD_TYPE)
    message(STATUS "CMAKE_BUILD_TYPE not given; setting to 'RelWithDebInfo'.")
    set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build." FORCE)
endif()

# compiler flags
if(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
add_definitions(-std=c99 -pipe -Wall -Wextra -Werror -Wformat
                -Wno-unused-parameter -Wno-unused-function -Wno-unused-label -Wpointer-arith -Wreturn-type -Wsign-compare -Wmultichar
                -Wshadow -Wcast-qual -Wmissing-prototypes -Wstrict-prototypes # -Wconversion
                -Winit-self -Wuninitialized -Wno-deprecated -Wformat-security -ffunction-sections -fdata-sections)
    if(NOT "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
        add_definitions(-Wformat-nonliteral)
        set (CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -Wl,--gc-sections")
        set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--gc-sections")
    else()
        add_definitions(-Wno-gnu-statement-expression)
    endif()
	if(NOT WIN32)
	    add_definitions(-fstack-protector -fPIC -fvisibility=hidden)
	endif()
endif()

# main sources of libopen62541
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/src")
file(GLOB_RECURSE exported_headers "${CMAKE_CURRENT_SOURCE_DIR}/include/*.h")
file(GLOB generated_headers "${PROJECT_BINARY_DIR}/src_generated/*.h")
set(lib_sources src/ua_types.c
                src/ua_types_encoding_binary.c
                ${PROJECT_BINARY_DIR}/src_generated/ua_types_generated.c
                ${PROJECT_BINARY_DIR}/src_generated/ua_transport_generated.c
                ${PROJECT_BINARY_DIR}/src_generated/ua_nodeids.h
                src/ua_securechannel.c
                src/ua_session.c
                src/server/ua_server.c
				src/server/ua_server_addressspace.c
				src/server/ua_server_binary.c
				src/server/ua_nodes.c
                src/server/ua_server_worker.c
                src/server/ua_securechannel_manager.c
                src/server/ua_session_manager.c
                src/server/ua_services_discovery.c
                src/server/ua_services_securechannel.c
                src/server/ua_services_session.c
                src/server/ua_services_attribute.c
                src/server/ua_services_nodemanagement.c
                src/server/ua_services_view.c
				${exported_headers}
				${generated_headers} )

## multithreading
option(MULTITHREADING "Enable multithreading" OFF)
if(MULTITHREADING)
    set(UA_MULTITHREADING ON)
    find_package(Threads REQUIRED)
    list(APPEND lib_sources src/server/ua_nodestore_concurrent.c)
else()
    list(APPEND lib_sources src/server/ua_nodestore.c)
endif()

## extensions
option(EXTENSION_UDP "Enable udp extension" OFF)
if(EXTENSION_UDP)
	set(EXTENSION_STATELESS ON)
	message(STATUS "Extensions: enabling udp")
	add_definitions(-DEXTENSION_UDP)
endif()

option(EXTENSION_STATELESS "Enable stateless extension" OFF)
if(EXTENSION_STATELESS)
	message(STATUS "Extensions: enabling stateless")
	add_definitions(-DEXTENSION_STATELESS)
endif()

add_library(open62541-objects OBJECT ${lib_sources})
add_library(open62541 SHARED $<TARGET_OBJECTS:open62541-objects>)
add_library(open62541-static STATIC $<TARGET_OBJECTS:open62541-objects>)
SET_TARGET_PROPERTIES(open62541-static PROPERTIES OUTPUT_NAME open62541 CLEAN_DIRECT_OUTPUT 1) # static version that exports all symbols
target_compile_definitions(open62541-objects PUBLIC UA_DYNAMIC_LINKING)

## logging
set(UA_LOGLEVEL 400 CACHE STRING "Level at which logs shall be reported")

## coverage
option(ENABLE_COVERAGE "Enable gcov coverage" OFF)
if(ENABLE_COVERAGE)
    message(STATUS "Enabling gcov support")
    set(CMAKE_BUILD_TYPE DEBUG)
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage")
    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage")
    set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fprofile-arcs -ftest-coverage")
endif()

# set the precompiler flags
configure_file("src/ua_config.h.in" "${PROJECT_BINARY_DIR}/src_generated/ua_config.h")

# generate code from xml definitions
file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/src_generated")
include_directories("${PROJECT_BINARY_DIR}/src_generated") <commit_msg>fixing mingw complile<commit_after>cmake_minimum_required(VERSION 2.8.8)
# set(CMAKE_VERBOSE_MAKEFILE on )

project(open62541 C)
set(open62541_VERSION_MAJOR 0)
set(open62541_VERSION_MINOR 0)
set(open62541_VERSION_PATCH 0)

set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")

# Set default build type.
if (NOT CMAKE_BUILD_TYPE)
    message(STATUS "CMAKE_BUILD_TYPE not given; setting to 'RelWithDebInfo'.")
    set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build." FORCE)
endif()

# compiler flags
if(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
add_definitions(-std=c99 -pipe -Wall -Wextra -Werror -Wformat
                -Wno-unused-parameter -Wno-unused-function -Wno-unused-label -Wpointer-arith -Wreturn-type -Wsign-compare -Wmultichar
                -Wshadow -Wcast-qual -Wmissing-prototypes -Wstrict-prototypes # -Wconversion
                -Winit-self -Wuninitialized -Wno-deprecated -Wformat-security -ffunction-sections -fdata-sections)
    if(NOT "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
        add_definitions(-Wformat-nonliteral)
        set (CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -Wl,--gc-sections")
        set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--gc-sections")
    else()
        add_definitions(-Wno-gnu-statement-expression)
    endif()
	if(NOT WIN32)
	    add_definitions(-fstack-protector -fPIC -fvisibility=hidden)
	endif()
endif()

# main sources of libopen62541
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/src")
file(GLOB_RECURSE exported_headers "${CMAKE_CURRENT_SOURCE_DIR}/include/*.h")
file(GLOB generated_headers "${PROJECT_BINARY_DIR}/src_generated/*.h")
set(lib_sources src/ua_types.c
                src/ua_types_encoding_binary.c
                ${PROJECT_BINARY_DIR}/src_generated/ua_types_generated.c
                ${PROJECT_BINARY_DIR}/src_generated/ua_transport_generated.c
                ${PROJECT_BINARY_DIR}/src_generated/ua_nodeids.h
                src/ua_securechannel.c
                src/ua_session.c
                src/server/ua_server.c
				src/server/ua_server_addressspace.c
				src/server/ua_server_binary.c
				src/server/ua_nodes.c
                src/server/ua_server_worker.c
                src/server/ua_securechannel_manager.c
                src/server/ua_session_manager.c
                src/server/ua_services_discovery.c
                src/server/ua_services_securechannel.c
                src/server/ua_services_session.c
                src/server/ua_services_attribute.c
                src/server/ua_services_nodemanagement.c
                src/server/ua_services_view.c
				${exported_headers}
				${generated_headers} )

## multithreading
option(MULTITHREADING "Enable multithreading" OFF)
if(MULTITHREADING)
    set(UA_MULTITHREADING ON)
    find_package(Threads REQUIRED)
    list(APPEND lib_sources src/server/ua_nodestore_concurrent.c)
else()
    list(APPEND lib_sources src/server/ua_nodestore.c)
endif()

## extensions
option(EXTENSION_UDP "Enable udp extension" OFF)
if(EXTENSION_UDP)
	set(EXTENSION_STATELESS ON)
	message(STATUS "Extensions: enabling udp")
	add_definitions(-DEXTENSION_UDP)
endif()

option(EXTENSION_STATELESS "Enable stateless extension" OFF)
if(EXTENSION_STATELESS)
	message(STATUS "Extensions: enabling stateless")
	add_definitions(-DEXTENSION_STATELESS)
endif()

add_library(open62541-objects OBJECT ${lib_sources})
add_library(open62541 SHARED $<TARGET_OBJECTS:open62541-objects>)
add_library(open62541-static STATIC $<TARGET_OBJECTS:open62541-objects>)
SET_TARGET_PROPERTIES(open62541-static PROPERTIES OUTPUT_NAME open62541 CLEAN_DIRECT_OUTPUT 1) # static version that exports all symbols
target_compile_definitions(open62541-objects PUBLIC UA_DYNAMIC_LINKING)
target_compile_definitions(open62541-static PUBLIC UA_DYNAMIC_LINKING)

## logging
set(UA_LOGLEVEL 400 CACHE STRING "Level at which logs shall be reported")

## coverage
option(ENABLE_COVERAGE "Enable gcov coverage" OFF)
if(ENABLE_COVERAGE)
    message(STATUS "Enabling gcov support")
    set(CMAKE_BUILD_TYPE DEBUG)
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage")
    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage")
    set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fprofile-arcs -ftest-coverage")
endif()

# set the precompiler flags
configure_file("src/ua_config.h.in" "${PROJECT_BINARY_DIR}/src_generated/ua_config.h")

# generate code from xml definitions
file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/src_generated")
include_directories("${PROJECT_BINARY_DIR}/src_generated") 
{'fraction_non_alphanumeric': 0.09778975741239893, 'fraction_numerical': 0.01757412398921833, 'mean_word_length': 4.352567801500289, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '1492317', 'n_tokens_mistral': 3408, 'n_tokens_neox': 3140, 'n_words': 503}