cc_project_template_cmake

A cmake, ninja, and googletest-based C++ project template
git clone https://git.bracken.jp/cc_project_template_cmake.git
Log | Files | Refs | Submodules | README | LICENSE

CMakeLists.txt (547B)


      1 add_definitions(-std=c++17)
      2 
      3 set(CXX_FLAGS
      4   "-Weverything"
      5   "-Wno-c++98-compat"
      6 )
      7 
      8 set(CXX_TEST_FLAGS
      9   ${CXX_FLAGS}
     10   "-Wno-global-constructors"
     11 )
     12 
     13 set(LIBFOO_SRCS
     14   foo.h
     15   foo.cc
     16   bar.h
     17   bar.cc
     18 )
     19 
     20 add_executable(main
     21   main.cc
     22   ${LIBFOO_SRCS}
     23 )
     24 target_compile_options(main PRIVATE ${CXX_FLAGS})
     25 
     26 set(LIBFOO_TEST_SRCS
     27   foo_test.cc
     28   bar_test.cc
     29 )
     30 
     31 add_executable(libfoo_tests
     32   ${LIBFOO_SRCS}
     33   ${LIBFOO_TEST_SRCS}
     34 )
     35 target_link_libraries(libfoo_tests
     36   gtest
     37   gtest_main
     38 )
     39 target_compile_options(libfoo_tests PRIVATE ${CXX_TEST_FLAGS})
     40