Commit 774d455dc720dc0d90d4d0bbdc57bde0ccb9f51d
1 parent
7081d818
Update CMakeLists to be more configurable
* Add cxxopts.hpp as a source file to executable * Add msvc options for compiling * Add CXXOPTS_BUILD_EXAMPLES option to CMake build * This is helpful when using CMake's ExternalProject_add() * It is ON by default, but configurable from the command-line.
Showing
3 changed files
with
11 additions
and
3 deletions
.gitignore
CMakeLists.txt
src/CMakeLists.txt
| ... | ... | @@ -18,9 +18,14 @@ |
| 18 | 18 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 19 | 19 | # THE SOFTWARE. |
| 20 | 20 | |
| 21 | -add_executable(example example.cpp) | |
| 21 | +if(CXXOPTS_BUILD_EXAMPLES) | |
| 22 | + add_executable(example example.cpp cxxopts.hpp) | |
| 22 | 23 | |
| 23 | -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall") | |
| 24 | -target_link_libraries(example ${CXXOPTS_LINKER_LIBRARIES}) | |
| 24 | + if (MSVC) | |
| 25 | + target_compile_options(example PUBLIC /W2) | |
| 26 | + elseif(CMAKE_CXX_COMPILER_ID MATCHES "[Cc]lang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU") | |
| 27 | + target_compile_options(example PUBLIC -std=c++11 -Wall) | |
| 28 | + endif() | |
| 29 | +endif() | |
| 25 | 30 | |
| 26 | 31 | install(FILES cxxopts.hpp DESTINATION include) | ... | ... |