Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions solutions/igor_kolupaev/tpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 2.8)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set( CMAKE_CONFIGURATION_TYPES ${CMAKE_BUILD_TYPE} CACHE STRING "Configurations" FORCE )
project( ${SOLUTION_NAME} )
include( environment.cmake required )

modules( multicast_communication )
binaries( market_data_receiver )

compile()
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
include( utils )

if (system_utilities_ROOT)
set(system_utilities_root ${system_utilities_ROOT} )
elseif(NOT "$ENV{SYSTEM_UTILITIES_ROOT}" STREQUAL "")
set(system_utilities_root $ENV{SYSTEM_UTILITIES_ROOT} )
else()
message(FATAL_ERROR "[ERROR]: No SYSTEM_UTILITIES_ROOT environment variable found")
endif()

if ("${CMAKE_BUILD_TYPE}" STREQUAL "")
set(CMAKE_BUILD_TYPE Debug)
if (!system_utilities_FIND_QUIETLY)
message(STATUS "CMAKE_BUILD_TYPE was not tuned, so we install there 'Debug'")
endif()
else()
endif()

if (system_utilities_DEBUG)
message(STATUS "We going to look into '${system_utilities_root}' (SYSTEM_UTILITIES_ROOT environment variable) folder.")
create_string_from_list( component_list ${system_utilities_FIND_COMPONENTS} )
message(STATUS "We are looking for: '" ${component_list} "' components.")
endif(system_utilities_DEBUG)

set(system_utilities_FOUND FALSE)
set(system_utilities_INCLUDE_DIRS "")
set(system_utilities_LIBRARIES "")

if (UNIX)
set(binary_search_folder ${system_utilities_root}/_build_${CMAKE_BUILD_TYPE}_${CMAKE_ADDRESS_MODEL}/bin_${CMAKE_ADDRESS_MODEL}/${CMAKE_BUILD_TYPE})
else(UNIX)
set(binary_search_folder ${system_utilities_root}/_build_${CMAKE_BUILD_TYPE}_${CMAKE_ADDRESS_MODEL}/bin_${CMAKE_ADDRESS_MODEL}/${CMAKE_BUILD_TYPE})
endif(UNIX)
if (NOT system_utilities_FIND_QUIETLY)
message(STATUS "Looking for libraries at " ${binary_search_folder})
endif()

if (system_utilities_DEBUG)
message(STATUS "Binary search folder: " ${binary_search_folder} )
endif(system_utilities_DEBUG)

set(components timer time_tracker ts_queue property_reader task_processor logger ts_logger queue_logger file_logger limited_file_logger system_processor windows_service)

foreach(component ${system_utilities_FIND_COMPONENTS})

list_contains(we_should_find_${component} ${component} ${components})
if(we_should_find_${component})

if (system_utilities_DEBUG)
message(STATUS "Searching for ${component} library. ")
endif()
set(system_utilities_${component}_FOUND FALSE)
set(system_utilities_${component}_INCLUDE_DIRS NOTFOUND)
set(system_utilities_${component}_LIBRARIES NOTFOUND)

find_path( system_utilities_${component}_INCLUDE_DIR
NAMES "${component}.h"
HINTS "${system_utilities_root}/sources/${component}/")
set(system_utilities_${component}_INCLUDE_DIRS ${system_utilities_${component}_INCLUDE_DIR})

find_library( system_utilities_${component}_LIBRARY
NAMES "${component}"
HINTS ${binary_search_folder} )
set(system_utilities_${component}_LIBRARIES ${system_utilities_${component}_LIBRARY})

if(NOT system_utilities_FIND_QUIETLY)
message(STATUS "system_utilities ${component} component: ")
create_string_from_list(headers ${system_utilities_${component}_INCLUDE_DIRS})
message(STATUS " headers : " ${headers})
create_string_from_list(libraries ${system_utilities_${component}_LIBRARIES})
message(STATUS " libraries: " ${libraries})
endif()

if(NOT system_utilities_${component}_INCLUDE_DIR OR NOT system_utilities_${component}_LIBRARY)
message(FATAL_ERROR " We can't find system_utilities ${component} component")
else()
set(system_utilities_INCLUDE_DIRS ${system_utilities_INCLUDE_DIRS} ${system_utilities_${component}_INCLUDE_DIRS})
set(system_utilities_LIBRARIES ${system_utilities_LIBRARIES} ${system_utilities_${component}_LIBRARIES})
endif()
else()
message(FATAL_ERROR "Unknown component: ${component}")
endif(we_should_find_${component})

endforeach( component )


if (system_utilities_DEBUG)
create_string_from_list(headers ${system_utilities_INCLUDE_DIRS})
message(STATUS "system_utilities_INCLUDE_DIRS: " ${headers})
create_string_from_list(libraries ${system_utilities_LIBRARIES})
message(STATUS "system_utilities_LIBRARIES: " ${libraries})
endif(system_utilities_DEBUG)

211 changes: 211 additions & 0 deletions solutions/igor_kolupaev/tpp/_cmake_scripts/utils.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@

macro( list_regex_contains var value)
set(${var})
foreach (iterator ${ARGN})
if ( iterator MATCHES "${value}" )
set(${var} TRUE)
endif( iterator MATCHES "${value}" )
endforeach (iterator)
endmacro( list_regex_contains )

macro( list_contains var value)
set(${var})
foreach (value2 ${ARGN})
if ("${value}" STREQUAL "${value2}")
set(${var} TRUE)
endif ("${value}" STREQUAL "${value2}")
endforeach (value2)
endmacro( list_contains )

function(test_variable_on_existance variable)
if (NOT ${variable})
MESSAGE( FATAL_ERROR "[ERROR: ] Variable ${variable} does not exist. Please set it by cmake -D${variable}=<value>." )
endif()
endfunction(test_variable_on_existance)

function(test_variable_on_equal_to_one_of_the_list variable)
list_contains(cmake_release_or_debug ${${variable}} ${ARGN} )
if (NOT cmake_release_or_debug)
create_string_from_list( str ${ARGN} )
MESSAGE( FATAL_ERROR " [ERROR: ] Variable ${variable} (${${variable}}) does not fit to any allow value (${str}).")
endif()
endfunction(test_variable_on_equal_to_one_of_the_list)

macro(create_string_from_list str)
foreach(VALUE ${ARGN})
if ("${VALUE}" STREQUAL "${ARGV0}")
set(result "${VALUE}")
else()
set(result "${result} ${VALUE}")
endif()
endforeach(VALUE)
set(${str} ${result})
endmacro(create_string_from_list)

macro( binaries )
set( ${SOLUTION_NAME}_binaries ${ARGN} )
endmacro( binaries )

macro( compile_binaries )
foreach (binary ${${SOLUTION_NAME}_binaries})
set( module_name ${binary} )
add_subdirectory( ${binary} )
endforeach( binary )
endmacro( compile_binaries )

macro( modules )
set( ${SOLUTION_NAME}_modules ${ARGN} )
foreach (module ${${SOLUTION_NAME}_modules})
set( ${module}_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/sources/${module} )
set( ${module}_LIBRARIES ${module} )
if ( ${VERBOSE} )
message(STATUS "Setting variables for ${module}")
message(STATUS " - directory: ${${module}_INCLUDE_DIRS}")
message(STATUS " - library: ${${module}_LIBRARIES}" )
endif( ${VERBOSE} )
endforeach( module )
endmacro( modules )

macro( compile_modules )
foreach (module ${${SOLUTION_NAME}_modules})
set( module_name ${module} )
add_subdirectory( ${module} )
endforeach( module )
endmacro( compile_modules )

macro( dlls )
set( ${SOLUTION_NAME}_dlls ${ARGN} )
foreach (module ${${SOLUTION_NAME}_dlls})
set( ${module}_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/sources/${module} )
set( ${module}_LIBRARIES ${module} )
if ( ${VERBOSE} )
message(STATUS "Setting variables for ${module}")
message(STATUS " - directory: ${${module}_INCLUDE_DIRS}")
message(STATUS " - library: ${${module}_LIBRARIES}" )
endif( ${VERBOSE} )
endforeach( module )
endmacro( dlls )

macro( compile_dlls )
foreach ( dll ${${SOLUTION_NAME}_dlls})
set( module_name ${dll} )
add_subdirectory( ${dll} )
endforeach( dll )
endmacro( compile_dlls )


macro( compile )
add_subdirectory( sources )
add_subdirectory( tests )
endmacro( compile )

macro( compile_tests )
if ( NOT BOOST_STATIC )
add_definitions( -DBOOST_TEST_DYN_LINK -DBOOST_TEST_NO_LIB )
endif( NOT BOOST_STATIC )

if (${RUN_PERFORMANCE_TESTS})
add_definitions( -DRUN_PERFORMANCE_TESTS )
endif(${RUN_PERFORMANCE_TESTS})
foreach (module ${${SOLUTION_NAME}_modules} )
if ( ${VERBOSE} )
message(STATUS "Compiling tests for ${module} module.")
endif( ${VERBOSE} )
set( module_name ${module} )
set( tests_name ${module}_tests )
add_subdirectory( ${tests_name} )
endforeach( module )
foreach (dll ${${SOLUTION_NAME}_dlls} )
if ( ${VERBOSE} )
message(STATUS "Compiling tests for ${module} dll.")
endif( ${VERBOSE} )
set( module_name ${dll} )
set( tests_name ${dll}_tests )
add_subdirectory( ${tests_name} )
endforeach( dll )
endmacro( compile_tests )

macro( add_source_list project_name source_folder source_dir )
file(GLOB ${project_name}_${source_folder}_SOURCE_LIST ${source_dir} )
set( ${project_name}_SOURCE_LIST ${${project_name}_SOURCE_LIST} ${${project_name}_${source_folder}_SOURCE_LIST} )
source_group( ${source_folder} FILES ${${project_name}_${source_folder}_SOURCE_LIST} )
endmacro( add_source_list )

macro( compile_project project_name source_pattern header_pattern build_type solution_folder )
project( ${project_name} )
if (${VERBOSE} )
message(STATUS "* Creating project: ${project_name}(${build_type}) with '${solution_folder}' (${PROJECT_SOURCE_DIR}) from: ${source_pattern}, ${header_pattern}.")
endif(${VERBOSE})

add_definitions( -DSOURCE_DIR="${CMAKE_SOURCE_DIR}" )
add_definitions( -DBINARY_DIR="${BINARIES_DIRECTORY}" )

file(GLOB ${project_name}_SOURCES ${source_pattern})
file(GLOB ${project_name}_HEADERS ${header_pattern})
file(GLOB ${project_name}_SOURCE_LIST ${${project_name}_SOURCE_LIST} ${${project_name}_SOURCES} ${${project_name}_HEADERS})

foreach( dependencie ${ARGN} )
if(${VERBOSE})
message(STATUS " - Adding thread dependencie: '${${dependencie}_INCLUDE_DIRS}'")
endif(${VERBOSE})
include_directories( ${${dependencie}_INCLUDE_DIRS} )
endforeach( dependencie )

if ("${build_type}" STREQUAL "STATIC")
add_library(${project_name} STATIC ${${project_name}_SOURCE_LIST} )
set( ${project_name}_INCLUDE_DIRS ${PROJECT_SOURCE_DIR} )
if(${VERBOSE})
message(STATUS " - Creating static library: ${project_name}")
endif(${VERBOSE})
elseif( "${build_type}" STREQUAL "SHARED" )
add_library(${project_name} SHARED ${${project_name}_SOURCE_LIST} )
set_property(TARGET ${project_name} PROPERTY LINK_INTERFACE_LIBRARIES "")
if(${VERBOSE})
message(STATUS " - Creating shared library: ${project_name}")
endif(${VERBOSE})
elseif( "${build_type}" STREQUAL "BINARY" )
add_executable( ${project_name} ${${project_name}_SOURCE_LIST})
if(${VERBOSE})
message(STATUS " - Creating binary file: ${project_name}")
endif(${VERBOSE})
endif()

if (NOT "${build_type}" STREQUAL "STATIC")
foreach( dependencie ${ARGN} )
target_link_libraries( ${project_name} ${${dependencie}_LIBRARIES} )
if(${VERBOSE})
message(STATUS " - Adding library dependencie: ${${dependencie}_LIBRARIES}")
endif(${VERBOSE})
endforeach( dependencie )
endif()

if ( NOT "${Boost_LIBRARIES}" STREQUAL "" )
list_regex_contains( boost_thread_in_dependencies "(.*)boost_thread(.*)" ${Boost_LIBRARIES} )
if ( boost_thread_in_dependencies AND UNIX )
target_link_libraries( ${project_name} pthread )
target_link_libraries( ${project_name} rt )
endif()
endif()

set_property(TARGET ${project_name} PROPERTY FOLDER ${solution_folder})

endmacro( compile_project )

macro( register_test project_name tests_time_out tests_with_performance_time_out )
add_test( ${project_name} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${project_name} )
if (${RUN_PERFORMANCE_TESTS})
set_tests_properties( ${PROJECT_NAME} PROPERTIES TIMEOUT ${tests_with_performance_time_out} )
else()
set_tests_properties( ${PROJECT_NAME} PROPERTIES TIMEOUT ${tests_time_out} )
endif(${RUN_PERFORMANCE_TESTS})
endmacro( register_test )

function(copy_config_file from to )
if (NOT COPY_FILES_BANNED)
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND "${CMAKE_COMMAND}" -E copy ${from} ${to} )
endif(NOT COPY_FILES_BANNED)
endfunction(copy_config_file)

function(copy_dll_file from to )
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND "${CMAKE_COMMAND}" -E copy ${from} ${to} )
endfunction(copy_dll_file)
22 changes: 22 additions & 0 deletions solutions/igor_kolupaev/tpp/_msvc_gen_2013_64.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
@echo off

set SOLUTION_NAME=trade_processor_project
set BOOST_ROOT=C:\Users\Public\libs\boost_1_55_0
set SYSTEM_UTILITIES_ROOT=C:\Users\Public\libs\system_utilities

set BUILD_TYPE=Debug
if [%1]==[Release] (
set BUILD_TYPE=Release
)
set BUILD_FOLDER=_build_%BUILD_TYPE%_64

if not exist %BUILD_FOLDER% (
mkdir %BUILD_FOLDER%
)

cd %BUILD_FOLDER%
cmake -DBOOST_STATIC=ON -DBOOST_STAGE_FOLDER_WITH_ADDRESS_MODEL=ON -DCMAKE_BUILD_TYPE=%BUILD_TYPE% -DSOLUTION_NAME=%SOLUTION_NAME% -G "Visual Studio 12 Win64" ../
cd ../

echo "%BUILD_FOLDER%/%SOLUTION_NAME%.sln" > _start_msvc.bat
pause
Loading