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

1
.gitignore vendored
View File

@@ -9,3 +9,4 @@ compile_commands.json
CTestTestfile.cmake
build
.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)
```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)
```CMake
@@ -215,13 +217,12 @@ endif()
CPMAddPackage(
NAME lua
GIT_REPOSITORY https://github.com/lua/lua.git
GIT_TAG v5-3-4
VERSION 5.3.4
VERSION 5.3.5
DOWNLOAD_ONLY YES
)
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)
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(
NAME Glue
GIT_REPOSITORY https://github.com/TheLartians/Glue.git
VERSION 0.8.1
VERSION 0.8.2
OPTIONS
"GLUE_ENABLE_LUA ON"
"GLUE_BUILD_LUA ON"

View File

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