diff --git a/.gitmodules b/.gitmodules index a762326..718b254 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,6 @@ [submodule "external/tiny-process-library"] path = external/tiny-process-library url = https://github.com/eidheim/tiny-process-library +[submodule "external/cxxopts"] + path = external/cxxopts + url = https://github.com/jarro2783/cxxopts diff --git a/CMakeLists.txt b/CMakeLists.txt index 05aadbb..e8809a7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,11 +15,28 @@ option(CPPAST_ENABLE_ASSERTIONS "whether or not to enable internal assertions fo option(CPPAST_ENABLE_PRECONDITION_CHECKS "whether or not to enable precondition checks" ON) option(CPPAST_BUILD_TEST "whether or not to build the tests" ON) +option(CPPAST_BUILD_TOOL "whether or not to build the tool" ON) +option(BUILD_TESTING "build test" OFF) # The ctest variable for building tests + +if(${CPPAST_BUILD_TEST} OR ${BUILD_TESTING} OR (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)) + set(build_test ON) +else() + set(build_test OFF) +endif() + +if(${CPPAST_BUILD_TOOL} OR (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)) + set(build_tool ON) +else() + set(build_tool OFF) +endif() include(external/external.cmake) add_subdirectory(src) -if(CPPAST_BUILD_TEST) + +if(${build_test}) add_subdirectory(test) endif() - +if(${build_tool}) + add_subdirectory(tool) +endif() diff --git a/external/cxxopts b/external/cxxopts new file mode 160000 index 0000000..1be5f10 --- /dev/null +++ b/external/cxxopts @@ -0,0 +1 @@ +Subproject commit 1be5f10daf6f08296eff399e82aa94d16800ef4e diff --git a/external/external.cmake b/external/external.cmake index 2fe9dee..1dd5e9a 100644 --- a/external/external.cmake +++ b/external/external.cmake @@ -38,6 +38,17 @@ target_include_directories(_cppast_tiny_process PUBLIC ${tiny_process_dir}) target_link_libraries(_cppast_tiny_process PUBLIC Threads::Threads) set_target_properties(_cppast_tiny_process PROPERTIES CXX_STANDARD 11) +# +# install cxxopts, if needed +# +if(build_tool) + message(STATUS "Installing cxxopts via submodule") + execute_process(COMMAND git submodule update --init -- external/cxxopts + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) + + add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/external/cxxopts EXCLUDE_FROM_ALL) +endif() + # # install libclang # diff --git a/tool/CMakeLists.txt b/tool/CMakeLists.txt new file mode 100644 index 0000000..8f3aaf0 --- /dev/null +++ b/tool/CMakeLists.txt @@ -0,0 +1,8 @@ +# Copyright (C) 2017 Jonathan Müller +# This file is subject to the license terms in the LICENSE file +# found in the top-level directory of this distribution. + +add_executable(cppast_tool main.cpp) +target_link_libraries(cppast_tool PUBLIC cppast cxxopts) +set_target_properties(cppast_tool PROPERTIES CXX_STANDARD 11 + OUTPUT_NAME cppast) diff --git a/tool/main.cpp b/tool/main.cpp new file mode 100644 index 0000000..385a9c5 --- /dev/null +++ b/tool/main.cpp @@ -0,0 +1,9 @@ +// Copyright (C) 2017 Jonathan Müller +// This file is subject to the license terms in the LICENSE file +// found in the top-level directory of this distribution. + +#include + +int main() +{ +}