<commit_before>#	opendatacon
 #
 #	Copyright (c) 2014:
 #
 #		DCrip3fJguWgVCLrZFfA7sIGgvx1Ou3fHfCxnrz4svAi
 #		yxeOtDhDCXf1Z4ApgXvX5ahqQmzRfJ2DoX8S05SqHA==
 #	
 #	Licensed under the Apache License, Version 2.0 (the "License");
 #	you may not use this file except in compliance with the License.
 #	You may obtain a copy of the License at
 #	
 #		http://www.apache.org/licenses/LICENSE-2.0
 #
 #	Unless required by applicable law or agreed to in writing, software
 #	distributed under the License is distributed on an "AS IS" BASIS,
 #	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 #	See the License for the specific language governing permissions and
 #	limitations under the License.
 #

option(SUPPRESS_ZERO_CHECK "Turn off the VS ZERO_CHECK config which runs everytime you build" OFF)
if(SUPPRESS_ZERO_CHECK)
	# If you dont want the ZERO_CHECK project in VS have the following line enabled.
	set(CMAKE_SUPPRESS_REGENERATION true)
endif()


if(WIN32)
	cmake_minimum_required(VERSION 3.4)
else()
	cmake_minimum_required(VERSION 2.8)
	set(BUILD_TYPE_INSTRUCTIONS "Choose the type of build, default Release, other options: Debug RelWithDebInfo MinSizeRel.")
	if(DEFINED CMAKE_BUILD_TYPE)
		set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING ${BUILD_TYPE_INSTRUCTIONS})
	else()
		set(CMAKE_BUILD_TYPE Release CACHE STRING ${BUILD_TYPE_INSTRUCTIONS})
	endif()
endif()

if(POLICY CMP0048)
	cmake_policy(SET CMP0048 OLD)
endif()

#macro for resolving chain of symlinks into a list
include(file_w_symlinks.cmake)

project(opendatacon_suite C CXX)
install(FILES "LICENSE.txt" DESTINATION ".")
install(FILES "NOTICE.txt" DESTINATION ".")
install(FILES "README.md" DESTINATION ".")
install(FILES "RELEASE_NOTES" DESTINATION ".")
install(DIRECTORY "./3rdPartyLicenses" DESTINATION ".")
install(DIRECTORY "install/init" DESTINATION ".")

#Deploy git workflow hook scripts
include(git-hooks.cmake)

#This will run on every build, because output is never actually produced.
add_custom_command(OUTPUT always_rebuild COMMAND ${CMAKE_COMMAND} -E echo)

#Generate version info now, and set to generate on every build
include(version.cmake)
add_custom_command(
	WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
	OUTPUT "${CMAKE_SOURCE_DIR}/include/opendatacon/Version.h"
	COMMAND ${CMAKE_COMMAND} -DBINARY_DIR=${CMAKE_BINARY_DIR} -DCURRENT_CONFIG=$<CONFIG> -P "version.cmake"
	DEPENDS always_rebuild
)
#version info target that our other targets can have a dependance on
add_custom_target(version DEPENDS "${CMAKE_SOURCE_DIR}/include/opendatacon/Version.h")

# various optional libraries and projects
option(FULL "Build all optional projects (DNP3Port, JSONPort, ModbusPort, PyPort, SimPort, MD3Port, CBPort, Tests, ConsoleUI, WebUI)" OFF)
option(USE_ASIO_SUBMODULE "Use git submodule to download asio header library" ON)
option(USE_SPDLOG_SUBMODULE "Use git submodule to download spdlog header library" ON)

set(TESTS OFF CACHE BOOL "Build tests")
set(WEBUI OFF CACHE BOOL "Build the http(s) web user interface")
set(DNP3PORT OFF CACHE BOOL "Build DNP3 Port")
set(JSONPORT OFF CACHE BOOL "Build JSON Port")
set(PYPORT OFF CACHE BOOL "Build Python Port")
set(MODBUSPORT OFF CACHE BOOL "Build Modbus Port")
set(SIMPORT OFF CACHE BOOL "Build Simulation Port")
set(MD3PORT OFF CACHE BOOL "Build MD3 Port")
set(CBPORT OFF CACHE BOOL "Build Conitel-Baker Port")
set(CONSOLEUI OFF CACHE BOOL "Build the console user interface")

# other options off-by-default that you can enable
option(WERROR "Set all warnings to errors" OFF)
option(COVERAGE "Builds the libraries with coverage info for gcov" OFF)

if(FULL)
	set(TESTS ON CACHE BOOL "Build tests" FORCE)
	set(WEBUI ON CACHE BOOL "Build the http(s) web user interface" FORCE)
	set(DNP3PORT ON CACHE BOOL "Build DNP3 Port" FORCE)
	set(JSONPORT ON CACHE BOOL "Build JSON Port" FORCE)
	set(PYPORT ON CACHE BOOL "Build Python Port" FORCE)
	set(MODBUSPORT ON CACHE BOOL "Build Modbus Port" FORCE)
	set(SIMPORT ON CACHE BOOL "Build Simulation Port" FORCE)
	set(MD3PORT ON CACHE BOOL "Build MD3 Port" FORCE)
	set(CBPORT ON CACHE BOOL "Build Conitel-Baker Port" FORCE)
	set(CONSOLEUI ON CACHE BOOL "Build the console user interface" FORCE)
endif()

# IDE configuration
set_property(GLOBAL PROPERTY USE_FOLDERS ON) #allows the creation of solution folders

# Platform configuration
if(WIN32)
	# for ASIO
	add_definitions(-D_WIN32_WINNT=0x0502)	
	add_definitions(-DASIO_HAS_STD_SYSTEM_ERROR)
	add_definitions(-DVC_EXTRALEAN)
	add_definitions(-DWIN32_LEAN_AND_MEAN)
	
	# Auto generate def files that export all symbols of STATIC libraries
	set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
	
	# UNICODE support
	add_definitions(-DUNICODE -D_UNICODE)
	
	# Postfix for debug builds
	SET(CMAKE_DEBUG_POSTFIX "d")
	install(CODE
	"
		if(\"\${CMAKE_INSTALL_CONFIG_NAME}\" STREQUAL \"Debug\")
			set(BUNDLE_LIB_POSTFIX ${CMAKE_DEBUG_POSTFIX})
		endif()
	")
	
	#min max macro rubbish
	add_definitions(-DNOMINMAX)

	# Install directories
	set(INSTALLDIR_BINS ".")
	set(INSTALLDIR_INCLUDES "include")
	set(INSTALLDIR_LIBS "lib")
	set(INSTALLDIR_SHARED ".")
	set(INSTALLDIR_MODULES ".")
endif()
if(UNIX)
	set(DL dl)
	set(RPATH_BASE $ORIGIN)

	# Install directories
	set(INSTALLDIR_BINS "bin")
	set(INSTALLDIR_INCLUDES "include")
	set(INSTALLDIR_LIBS "lib")
	set(INSTALLDIR_SHARED "lib")
	set(INSTALLDIR_MODULES "plugin")
endif()
if(APPLE)
	set(CMAKE_MACOSX_RPATH 1)
	set(RPATH_BASE @executable_path)

	# Install directories
	set(INSTALLDIR_BINS "bin")
	set(INSTALLDIR_INCLUDES "include")
	set(INSTALLDIR_LIBS "lib")
	set(INSTALLDIR_SHARED "lib")
	set(INSTALLDIR_MODULES "plugin")
endif()

# Compiler configuration
add_definitions(-DASIO_STANDALONE) # required for ASIO in C++11 only mode

#uncomment below to debug asio handlers on stderr
#add_definitions(-DASIO_ENABLE_HANDLER_TRACKING)

if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
	# using Visual Studio C++
	message("CMAKE configuring opendatacon for Visual Studio C++" )
	set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3 /MP")
	# tell asio to only compile once (where <asio/impl/src.hpp> is included)
	# use CXX_FLAGS (instead of add_definitions) so we can use it for external libraries too
	set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /DASIO_SEPARATE_COMPILATION")

elseif(CMAKE_CXX_COMPILER_ID MATCHES "Intel")
	# using Intel C++
	message(WARNING "opendatacon has not been tested using Intel compiler" )
	
else()#if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
	# using Clang or GNU compilers
	message("-- configuring opendatacon for  Clang or GNU compilers" )
	if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
		set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
	endif()
	if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
		message("using special options for GNU compiler")
		#--no-gnu-unique is required for true dynamic loading and unloading of shared libs
		set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --no-gnu-unique")
		#now some trickery to see which glibc
		execute_process(<commit_msg>MSVC needs to be coerced into c++11 compliance with rvals [skip travis]<commit_after>#	opendatacon
 #
 #	Copyright (c) 2014:
 #
 #		DCrip3fJguWgVCLrZFfA7sIGgvx1Ou3fHfCxnrz4svAi
 #		yxeOtDhDCXf1Z4ApgXvX5ahqQmzRfJ2DoX8S05SqHA==
 #	
 #	Licensed under the Apache License, Version 2.0 (the "License");
 #	you may not use this file except in compliance with the License.
 #	You may obtain a copy of the License at
 #	
 #		http://www.apache.org/licenses/LICENSE-2.0
 #
 #	Unless required by applicable law or agreed to in writing, software
 #	distributed under the License is distributed on an "AS IS" BASIS,
 #	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 #	See the License for the specific language governing permissions and
 #	limitations under the License.
 #

option(SUPPRESS_ZERO_CHECK "Turn off the VS ZERO_CHECK config which runs everytime you build" OFF)
if(SUPPRESS_ZERO_CHECK)
	# If you dont want the ZERO_CHECK project in VS have the following line enabled.
	set(CMAKE_SUPPRESS_REGENERATION true)
endif()


if(WIN32)
	cmake_minimum_required(VERSION 3.4)
else()
	cmake_minimum_required(VERSION 2.8)
	set(BUILD_TYPE_INSTRUCTIONS "Choose the type of build, default Release, other options: Debug RelWithDebInfo MinSizeRel.")
	if(DEFINED CMAKE_BUILD_TYPE)
		set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING ${BUILD_TYPE_INSTRUCTIONS})
	else()
		set(CMAKE_BUILD_TYPE Release CACHE STRING ${BUILD_TYPE_INSTRUCTIONS})
	endif()
endif()

if(POLICY CMP0048)
	cmake_policy(SET CMP0048 OLD)
endif()

#macro for resolving chain of symlinks into a list
include(file_w_symlinks.cmake)

project(opendatacon_suite C CXX)
install(FILES "LICENSE.txt" DESTINATION ".")
install(FILES "NOTICE.txt" DESTINATION ".")
install(FILES "README.md" DESTINATION ".")
install(FILES "RELEASE_NOTES" DESTINATION ".")
install(DIRECTORY "./3rdPartyLicenses" DESTINATION ".")
install(DIRECTORY "install/init" DESTINATION ".")

#Deploy git workflow hook scripts
include(git-hooks.cmake)

#This will run on every build, because output is never actually produced.
add_custom_command(OUTPUT always_rebuild COMMAND ${CMAKE_COMMAND} -E echo)

#Generate version info now, and set to generate on every build
include(version.cmake)
add_custom_command(
	WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
	OUTPUT "${CMAKE_SOURCE_DIR}/include/opendatacon/Version.h"
	COMMAND ${CMAKE_COMMAND} -DBINARY_DIR=${CMAKE_BINARY_DIR} -DCURRENT_CONFIG=$<CONFIG> -P "version.cmake"
	DEPENDS always_rebuild
)
#version info target that our other targets can have a dependance on
add_custom_target(version DEPENDS "${CMAKE_SOURCE_DIR}/include/opendatacon/Version.h")

# various optional libraries and projects
option(FULL "Build all optional projects (DNP3Port, JSONPort, ModbusPort, PyPort, SimPort, MD3Port, CBPort, Tests, ConsoleUI, WebUI)" OFF)
option(USE_ASIO_SUBMODULE "Use git submodule to download asio header library" ON)
option(USE_SPDLOG_SUBMODULE "Use git submodule to download spdlog header library" ON)

set(TESTS OFF CACHE BOOL "Build tests")
set(WEBUI OFF CACHE BOOL "Build the http(s) web user interface")
set(DNP3PORT OFF CACHE BOOL "Build DNP3 Port")
set(JSONPORT OFF CACHE BOOL "Build JSON Port")
set(PYPORT OFF CACHE BOOL "Build Python Port")
set(MODBUSPORT OFF CACHE BOOL "Build Modbus Port")
set(SIMPORT OFF CACHE BOOL "Build Simulation Port")
set(MD3PORT OFF CACHE BOOL "Build MD3 Port")
set(CBPORT OFF CACHE BOOL "Build Conitel-Baker Port")
set(CONSOLEUI OFF CACHE BOOL "Build the console user interface")

# other options off-by-default that you can enable
option(WERROR "Set all warnings to errors" OFF)
option(COVERAGE "Builds the libraries with coverage info for gcov" OFF)

if(FULL)
	set(TESTS ON CACHE BOOL "Build tests" FORCE)
	set(WEBUI ON CACHE BOOL "Build the http(s) web user interface" FORCE)
	set(DNP3PORT ON CACHE BOOL "Build DNP3 Port" FORCE)
	set(JSONPORT ON CACHE BOOL "Build JSON Port" FORCE)
	set(PYPORT ON CACHE BOOL "Build Python Port" FORCE)
	set(MODBUSPORT ON CACHE BOOL "Build Modbus Port" FORCE)
	set(SIMPORT ON CACHE BOOL "Build Simulation Port" FORCE)
	set(MD3PORT ON CACHE BOOL "Build MD3 Port" FORCE)
	set(CBPORT ON CACHE BOOL "Build Conitel-Baker Port" FORCE)
	set(CONSOLEUI ON CACHE BOOL "Build the console user interface" FORCE)
endif()

# IDE configuration
set_property(GLOBAL PROPERTY USE_FOLDERS ON) #allows the creation of solution folders

# Platform configuration
if(WIN32)
	# for ASIO
	add_definitions(-D_WIN32_WINNT=0x0502)	
	add_definitions(-DASIO_HAS_STD_SYSTEM_ERROR)
	add_definitions(-DVC_EXTRALEAN)
	add_definitions(-DWIN32_LEAN_AND_MEAN)
	
	# Auto generate def files that export all symbols of STATIC libraries
	set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
	
	# UNICODE support
	add_definitions(-DUNICODE -D_UNICODE)
	
	# Postfix for debug builds
	SET(CMAKE_DEBUG_POSTFIX "d")
	install(CODE
	"
		if(\"\${CMAKE_INSTALL_CONFIG_NAME}\" STREQUAL \"Debug\")
			set(BUNDLE_LIB_POSTFIX ${CMAKE_DEBUG_POSTFIX})
		endif()
	")
	
	#min max macro rubbish
	add_definitions(-DNOMINMAX)

	# Install directories
	set(INSTALLDIR_BINS ".")
	set(INSTALLDIR_INCLUDES "include")
	set(INSTALLDIR_LIBS "lib")
	set(INSTALLDIR_SHARED ".")
	set(INSTALLDIR_MODULES ".")
endif()
if(UNIX)
	set(DL dl)
	set(RPATH_BASE $ORIGIN)

	# Install directories
	set(INSTALLDIR_BINS "bin")
	set(INSTALLDIR_INCLUDES "include")
	set(INSTALLDIR_LIBS "lib")
	set(INSTALLDIR_SHARED "lib")
	set(INSTALLDIR_MODULES "plugin")
endif()
if(APPLE)
	set(CMAKE_MACOSX_RPATH 1)
	set(RPATH_BASE @executable_path)

	# Install directories
	set(INSTALLDIR_BINS "bin")
	set(INSTALLDIR_INCLUDES "include")
	set(INSTALLDIR_LIBS "lib")
	set(INSTALLDIR_SHARED "lib")
	set(INSTALLDIR_MODULES "plugin")
endif()

# Compiler configuration
add_definitions(-DASIO_STANDALONE) # required for ASIO in C++11 only mode

#uncomment below to debug asio handlers on stderr
#add_definitions(-DASIO_ENABLE_HANDLER_TRACKING)

if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
	# using Visual Studio C++
	message("CMAKE configuring opendatacon for Visual Studio C++" )
	set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3 /MP /Zc:rvalueCast")
	# tell asio to only compile once (where <asio/impl/src.hpp> is included)
	# use CXX_FLAGS (instead of add_definitions) so we can use it for external libraries too
	set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /DASIO_SEPARATE_COMPILATION")

elseif(CMAKE_CXX_COMPILER_ID MATCHES "Intel")
	# using Intel C++
	message(WARNING "opendatacon has not been tested using Intel compiler" )
	
else()#if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
	# using Clang or GNU compilers
	message("-- configuring opendatacon for  Clang or GNU compilers" )
	if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
		set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
	endif()
	if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
		message("using special options for GNU compiler")
		#--no-gnu-unique is required for true dynamic loading and unloading of shared libs
		set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --no-gnu-unique")
		#now some trickery to see which glibc
		execute_process(
{'fraction_non_alphanumeric': 0.0902812388750445, 'fraction_numerical': 0.008686365254538982, 'mean_word_length': 5.919211822660099, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1248215', 'n_tokens_mistral': 5276, 'n_tokens_neox': 4927, 'n_words': 1449}