add cxxopts example and update lua (#73)

* add cxxopts example

* use new tags for lua

* update readme

* update readme

* update lua

* typo
This commit is contained in:
Lars Melchior
2019-07-24 11:48:50 +02:00
committed by GitHub
parent 64f5fe37cd
commit a6bc65a76c
6 changed files with 67 additions and 19 deletions

3
.gitignore vendored
View File

@@ -8,4 +8,5 @@ install_manifest.txt
compile_commands.json compile_commands.json
CTestTestfile.cmake CTestTestfile.cmake
build build
.vscode .vscode
.DS_Store

View File

@@ -120,17 +120,6 @@ CPMAddPackage(
) )
``` ```
### [Doctest](https://github.com/onqtam/doctest)
```cmake
CPMAddPackage(
NAME doctest
GITHUB_REPOSITORY onqtam/doctest
GIT_TAG 2.3.2
)
```
### [Boost (via boost-cmake)](https://github.com/Orphis/boost-cmake) ### [Boost (via boost-cmake)](https://github.com/Orphis/boost-cmake)
```CMake ```CMake
@@ -141,6 +130,19 @@ CPMAddPackage(
) )
``` ```
### [cxxopts](https://github.com/jarro2783/cxxopts)
```cmake
CPMAddPackage(
NAME cxxopts
GITHUB_REPOSITORY jarro2783/cxxopts
VERSION 2.2.0
OPTIONS
"CXXOPTS_BUILD_EXAMPLES Off"
"CXXOPTS_BUILD_TESTS Off"
)
```
### [Yaml-cpp](https://github.com/jbeder/yaml-cpp) ### [Yaml-cpp](https://github.com/jbeder/yaml-cpp)
```CMake ```CMake
@@ -148,7 +150,7 @@ CPMAddPackage(
NAME yaml-cpp NAME yaml-cpp
GITHUB_REPOSITORY jbeder/yaml-cpp GITHUB_REPOSITORY jbeder/yaml-cpp
# 0.6.2 uses depricated CMake syntax # 0.6.2 uses depricated CMake syntax
VERSION 0.6.3 VERSION 0.6.3
# 0.6.3 is not released yet, so use a recent commit # 0.6.3 is not released yet, so use a recent commit
GIT_TAG 012269756149ae99745b6dafefd415843d7420bb GIT_TAG 012269756149ae99745b6dafefd415843d7420bb
OPTIONS OPTIONS
@@ -215,13 +217,12 @@ endif()
CPMAddPackage( CPMAddPackage(
NAME lua NAME lua
GIT_REPOSITORY https://github.com/lua/lua.git GIT_REPOSITORY https://github.com/lua/lua.git
GIT_TAG v5-3-4 VERSION 5.3.5
VERSION 5.3.4
DOWNLOAD_ONLY YES DOWNLOAD_ONLY YES
) )
if (lua_ADDED) if (lua_ADDED)
# lua has no CMakeLists, so we create our own target # lua has no CMake support, so we create our own target
FILE(GLOB lua_sources ${lua_SOURCE_DIR}/*.c) FILE(GLOB lua_sources ${lua_SOURCE_DIR}/*.c)
add_library(lua STATIC ${lua_sources}) add_library(lua STATIC ${lua_sources})

View File

@@ -0,0 +1,24 @@
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
# ---- Options ----
option(ENABLE_TEST_COVERAGE "Enable test coverage" OFF)
# ---- Dependencies ----
include(../../cmake/CPM.cmake)
CPMAddPackage(
NAME cxxopts
GITHUB_REPOSITORY jarro2783/cxxopts
VERSION 2.2.0
OPTIONS
"CXXOPTS_BUILD_EXAMPLES Off"
"CXXOPTS_BUILD_TESTS Off"
)
# ---- Create binary ----
add_executable(CPMExampleCXXOpts main.cpp)
target_link_libraries(CPMExampleCXXOpts cxxopts)
set_target_properties(CPMExampleCXXOpts PROPERTIES CXX_STANDARD 17 COMPILE_FLAGS "-Wall -pedantic -Wextra -Werror")

23
examples/cxxopts/main.cpp Normal file
View File

@@ -0,0 +1,23 @@
#include <cxxopts.hpp>
#include <iostream>
int main(int argc, char ** argv) {
cxxopts::Options options("MyProgram", "One line description of MyProgram");
options.add_options()
("h,help", "Show help")
("d,debug", "Enable debugging")
("f,file", "File name", cxxopts::value<std::string>());
auto result = options.parse(argc, argv);
if (result["help"].as<bool>()) {
std::cout << options.help() << std::endl;
return 0;
}
for (auto arg: result.arguments()) {
std::cout << "option: " << arg.key() << ": " << arg.value() << std::endl;
}
return 0;
}

View File

@@ -7,7 +7,7 @@ include(../../cmake/CPM.cmake)
CPMAddPackage( CPMAddPackage(
NAME Glue NAME Glue
GIT_REPOSITORY https://github.com/TheLartians/Glue.git GIT_REPOSITORY https://github.com/TheLartians/Glue.git
VERSION 0.8.1 VERSION 0.8.2
OPTIONS OPTIONS
"GLUE_ENABLE_LUA ON" "GLUE_ENABLE_LUA ON"
"GLUE_BUILD_LUA ON" "GLUE_BUILD_LUA ON"

View File

@@ -7,8 +7,7 @@ include(../../cmake/CPM.cmake)
CPMAddPackage( CPMAddPackage(
NAME lua NAME lua
GIT_REPOSITORY https://github.com/lua/lua.git GIT_REPOSITORY https://github.com/lua/lua.git
VERSION 5.3.4 VERSION 5.3.5
GIT_TAG v5-3-4
DOWNLOAD_ONLY YES DOWNLOAD_ONLY YES
) )