Fixes #33. This PR uses cmake's interface library feature: An INTERFACE library target does not directly create build output, though it may have properties set on it and it may be installed, exported and imported. This makes it easier to include the header only library in a cmake project. After using add_subdirectory on the cxxopts directory, one simply needs to include cxxopts in their target_link_libraries, which will allow the user's target to inherit the properties of the cxxopts header library (see changes to example and test).
14 lines
407 B
CMake
14 lines
407 B
CMake
if (CXXOPTS_BUILD_TESTS)
|
|
add_executable(options_test options.cpp)
|
|
target_link_libraries(options_test cxxopts)
|
|
|
|
if (MSVC)
|
|
target_compile_options(options_test PUBLIC /W2)
|
|
elseif(CMAKE_CXX_COMPILER_ID MATCHES "[Cc]lang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
|
target_compile_options(options_test PUBLIC -std=c++11 -Wall)
|
|
endif()
|
|
|
|
add_test(options options_test)
|
|
endif()
|
|
|