diff --git a/CMakeLists.txt b/CMakeLists.txt index f98109382..b9c7831c8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,10 +1,13 @@ cmake_minimum_required(VERSION 3.3) -project(Algorithms_in_C - LANGUAGES C CXX +project(Algorithms_in_C++ + LANGUAGES CXX VERSION 1.0.0 DESCRIPTION "Set of algorithms implemented in C." ) +# set(CMAKE_CXX_CPPLINT "~/anaconda3/bin/cpplint --filter=-legal/copyright --std=c++11") +# find_program(CLANG_FORMAT "clang-format") + option(USE_OPENMP "flag to use OpenMP for multithreading" ON) cmake_policy(SET CMP0054 NEW) @@ -34,32 +37,17 @@ if(DOXYGEN_FOUND) ) endif() -function(function_timer) - set(CMAKE_BUILD_TYPE "Release") # This is local to function - add_subdirectory(function_timer EXCLUDE_FROM_ALL) -endfunction() - -function_timer() - -include_directories(function_timer/include) -# link_libraries(function_timer) -# include_directories(${CMAKE_BINARY_DIR}/include) -# link_directories(${CMAKE_BINARY_DIR}/lib/${CMAKE_BUILD_TYPE}) - -set(CMAKE_C_STANDARD 11) -set(CMAKE_C_STANDARD_REQUIRED ON) +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) if(MSVC) add_compile_definitions(_CRT_SECURE_NO_WARNINGS) add_compile_options(/Za) endif(MSVC) -add_subdirectory(conversions) -add_subdirectory(misc) -add_subdirectory(project_euler) -add_subdirectory(sorting) -add_subdirectory(searching) -add_subdirectory(numerical_methods) +add_subdirectory(math) +add_subdirectory(others) +add_subdirectory(computer_oriented_statistical_methods) if(USE_OPENMP) find_package(OpenMP) diff --git a/computer_oriented_statistical_methods/CMakeLists.txt b/computer_oriented_statistical_methods/CMakeLists.txt new file mode 100644 index 000000000..acff1ed1c --- /dev/null +++ b/computer_oriented_statistical_methods/CMakeLists.txt @@ -0,0 +1,18 @@ +# If necessary, use the RELATIVE flag, otherwise each source file may be listed +# with full pathname. RELATIVE may makes it easier to extract an executable name +# automatically. +file( GLOB APP_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp ) +# file( GLOB APP_SOURCES ${CMAKE_SOURCE_DIR}/*.c ) +# AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} APP_SOURCES) +foreach( testsourcefile ${APP_SOURCES} ) + # I used a simple string replace, to cut off .cpp. + string( REPLACE ".cpp" "" testname ${testsourcefile} ) + add_executable( ${testname} ${testsourcefile} ) + + set_target_properties(${testname} PROPERTIES LINKER_LANGUAGE CXX) + if(OpenMP_CXX_FOUND) + target_link_libraries(${testname} OpenMP::OpenMP_CXX) + endif() + install(TARGETS ${testname} DESTINATION "bin/stats") + +endforeach( testsourcefile ${APP_SOURCES} ) diff --git a/math/CMakeLists.txt b/math/CMakeLists.txt new file mode 100644 index 000000000..2b70b2d31 --- /dev/null +++ b/math/CMakeLists.txt @@ -0,0 +1,18 @@ +# If necessary, use the RELATIVE flag, otherwise each source file may be listed +# with full pathname. RELATIVE may makes it easier to extract an executable name +# automatically. +file( GLOB APP_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp ) +# file( GLOB APP_SOURCES ${CMAKE_SOURCE_DIR}/*.c ) +# AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} APP_SOURCES) +foreach( testsourcefile ${APP_SOURCES} ) + # I used a simple string replace, to cut off .cpp. + string( REPLACE ".cpp" "" testname ${testsourcefile} ) + add_executable( ${testname} ${testsourcefile} ) + + set_target_properties(${testname} PROPERTIES LINKER_LANGUAGE CXX) + if(OpenMP_CXX_FOUND) + target_link_libraries(${testname} OpenMP::OpenMP_CXX) + endif() + install(TARGETS ${testname} DESTINATION "bin/math") + +endforeach( testsourcefile ${APP_SOURCES} ) diff --git a/others/CMakeLists.txt b/others/CMakeLists.txt new file mode 100644 index 000000000..f049b5f2d --- /dev/null +++ b/others/CMakeLists.txt @@ -0,0 +1,18 @@ +# If necessary, use the RELATIVE flag, otherwise each source file may be listed +# with full pathname. RELATIVE may makes it easier to extract an executable name +# automatically. +file( GLOB APP_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp ) +# file( GLOB APP_SOURCES ${CMAKE_SOURCE_DIR}/*.c ) +# AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} APP_SOURCES) +foreach( testsourcefile ${APP_SOURCES} ) + # I used a simple string replace, to cut off .cpp. + string( REPLACE ".cpp" "" testname ${testsourcefile} ) + add_executable( ${testname} ${testsourcefile} ) + + set_target_properties(${testname} PROPERTIES LINKER_LANGUAGE CXX) + if(OpenMP_CXX_FOUND) + target_link_libraries(${testname} OpenMP::OpenMP_CXX) + endif() + install(TARGETS ${testname} DESTINATION "bin/others") + +endforeach( testsourcefile ${APP_SOURCES} )