CMakeLists.txt 998 B

1234567891011121314151617181920212223242526
  1. cmake_minimum_required(VERSION 3.0)
  2. include(FindPkgConfig)
  3. pkg_check_modules(CURLPP REQUIRED curlpp)
  4. set(CMAKE_CXX_STANDARD 11) # C++11...
  5. set(CMAKE_CXX_STANDARD_REQUIRED ON) #...is required...
  6. set(CMAKE_CXX_EXTENSIONS OFF) #...without compiler extensions like gnu++11
  7. file(GLOB ExamplesFileList "*.cpp")
  8. # Create a meta target to create examples
  9. add_custom_target(build_all_examples COMMENT A target that requires all the examples.)
  10. message(STATUS "Creating build rules for Examples:")
  11. foreach(Example ${ExamplesFileList})
  12. message(STATUS "\tCreating build rule for ${Example}")
  13. # Get the name without extension or directory
  14. get_filename_component(ExampleName ${Example} NAME_WE)
  15. # Define example executable
  16. add_executable(${ExampleName} ${Example})
  17. # Link example against curlpp
  18. target_link_libraries(${ExampleName} ${CURLPP_LDFLAGS})
  19. # make the meta target depend on this example.
  20. add_dependencies(build_all_examples ${ExampleName})
  21. endforeach(Example ${ExamplesFileList})