Advertisement
froleyks

CMakeLists.txt

Dec 2nd, 2018
695
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CMake 2.84 KB | None | 0 0
  1. cmake_minimum_required (VERSION 2.8)
  2.  
  3. #### USER DEFINED ##############################################################
  4.  
  5. #### BASIC SETTINGS ############################################################
  6.  
  7. include_directories(.)
  8.  
  9. set (CMAKE_CXX_FLAGS "-std=c++1z -msse4.2 -Wall -Wextra -O3 -g -fopenmp")
  10.  
  11. set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
  12. set(THREADS_PREFER_PTHREAD_FLAG TRUE)
  13. find_package(Threads REQUIRED)
  14.  
  15. #### TARGETS ###################################################################
  16.  
  17. function( addEx name cpp )
  18.   add_executable(${name} ${cpp})
  19.   target_compile_options(${name}
  20.     PRIVATE
  21.     -Wall
  22.     # -Wextra # reasonable and standard
  23.     # -Wshadow # warn the user if a variable declaration shadows one from a
  24.     # # parent context
  25.     # -Wnon-virtual-dtor # warn the user if a class with virtual functions has a
  26.     # # non-virtual destructor. This helps catch hard to
  27.     # # track down memory errors
  28.     # -Wold-style-cast # warn for c-style casts
  29.     # -Wcast-align # warn for potential performance problem casts
  30.     # -Wunused # warn on anything being unused
  31.     # -Woverloaded-virtual # warn if you overload (not override) a virtual
  32.     # # function
  33.     # -Wpedantic # warn if non-standard C++ is used
  34.     # -Wconversion # warn on type conversions that may lose data
  35.     # -Wsign-conversion # warn on sign conversions
  36.     # -Wmisleading-indentation # warn if identation implies blocks where blocks
  37.     # # do not exist
  38.     # -Wduplicated-cond # warn if if / else chain has duplicated conditions
  39.     # -Wduplicated-branches # warn if if / else branches have duplicated code
  40.     # -Wlogical-op # warn about logical operations being used where bitwise were
  41.     # # probably wanted
  42.     # -Wnull-dereference # warn if a null dereference is detected
  43.     # -Wuseless-cast # warn if you perform a cast to the same type
  44.     # -Wdouble-promotion # warn if float is implicit promoted to double
  45.     # -Wformat=2 # warn on security issues around functions that format output
  46.     # -Weffc++
  47.     # # (ie printf)
  48.     )
  49. endfunction( addEx )
  50.  
  51.  
  52.  
  53. # add_executable(test_correctness tests/correctness.cpp)
  54. addEx(test_correctness tests/correctness.cpp)
  55. target_sources(test_correctness PRIVATE implementation/dynamic_connectivity.hpp)
  56. target_link_libraries(test_correctness Threads::Threads)
  57.  
  58. # add_executable(graph_construction tools/graph_generator.cpp)
  59. addEx(graph_construction tools/graph_generator.cpp)
  60. target_sources(graph_construction PRIVATE tools/graph_generator.cpp)
  61. #target_link_libraries(graph_construction Threads::Threads)
  62.  
  63. # 3.1
  64.  
  65. find_package(OpenMP REQUIRED)
  66. set(OMP_LIBRARIES     OpenMP::OpenMP_CXX)
  67.  
  68. addEx(sum_omp implementation/sum.cpp)
  69. target_link_libraries(sum_omp ${OMP_LIBRARIES})
  70. target_compile_definitions(sum_omp PRIVATE -D OMP)
  71.  
  72. addEx(sum_no implementation/sum.cpp)
  73.  
  74. add_custom_target(run_sum_omp
  75.   ./sum_omp
  76.   DEPENDS sum_omp
  77. )
  78.  
  79. add_custom_target(run_sum_no
  80.   ./sum_no
  81.   DEPENDS sum_no
  82. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement