Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make snowhouse a CMake library #38

Merged
merged 1 commit into from
Jan 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ environment:
- CXX_STANDARD: 14

build_script:
- cmake -G "Visual Studio 14" -DSNOWHOUSE_RUN_TESTS=0 -DSNOWHOUSE_CXX_STANDARD=C++%CXX_STANDARD%
- cmake -G "Visual Studio 14" -DSNOWHOUSE_RUN_TESTS=0 -DSNOWHOUSE_BUILD_TESTS=1 -DSNOWHOUSE_CXX_STANDARD=C++%CXX_STANDARD%
- cmake --build .
test_script:
- bin\Debug\snowhouse-tests.exe
14 changes: 11 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ cmake_minimum_required(VERSION 2.8)

project(snowhouse)

option(SNOWHOUSE_BUILD_TESTS "Build the Snowhouse tests" ON)
option(SNOWHOUSE_RUN_TESTS "Run the Snowhouse tests" ON)
option(SNOWHOUSE_BUILD_TESTS "Build the Snowhouse tests" OFF)
option(SNOWHOUSE_RUN_TESTS "Run the Snowhouse tests" OFF)
HauserV marked this conversation as resolved.
Show resolved Hide resolved
set(SNOWHOUSE_CXX_STANDARD "C++03" CACHE STRING "The C++ standard the examples are compiled with")
set_property(CACHE SNOWHOUSE_CXX_STANDARD PROPERTY STRINGS "C++98" "C++03" "C++11" "C++14")

include_directories("${PROJECT_SOURCE_DIR}")
if (NOT ${CMAKE_VERSION} VERSION_LESS "3.0.0")
add_library(snowhouse INTERFACE)
target_include_directories(snowhouse INTERFACE include)
endif()

if(SNOWHOUSE_CXX_STANDARD STREQUAL "C++98")
set(std_name "c++98")
Expand Down Expand Up @@ -45,6 +48,11 @@ message(STATUS "C++ compiler flags: ${CMAKE_CXX_FLAGS}")
if (SNOWHOUSE_BUILD_TESTS)
FILE(GLOB SnowhouseSpecSourceFiles example/*.cpp)
add_executable(snowhouse-tests ${SnowhouseSpecSourceFiles})
if (NOT ${CMAKE_VERSION} VERSION_LESS "3.0.0")
target_link_libraries(snowhouse-tests PRIVATE snowhouse)
else()
include_directories("${PROJECT_SOURCE_DIR}/include")
endif()
endif()

if (SNOWHOUSE_BUILD_TESTS AND SNOWHOUSE_RUN_TESTS)
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ git submodule add -b headers-only https://github.com/banditcpp/snowhouse snowhou
git submodule update --init --recursive
```

As an alternative, CMake >= 3.0 users can use Snowhouse with the provided library target.
Assuming you have cloned the `master` branch into a `snowhouse` subdirectory,
your `CMakeLists.txt` might contain lines like the following:

```cmake
add_subdirectory(snowhouse)
add_executable(app main.cpp)
target_link_libraries(app snowhouse)
```

## Usage

```C++
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion util/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ echo " * build path: $buildpath"

mkdir -p "$SRCDIR/$buildpath"
cd "$SRCDIR/$buildpath" || exit
cmake -D"SNOWHOUSE_CXX_STANDARD=C++$cxxstandard" "$SRCDIR" || exit
cmake -DSNOWHOUSE_BUILD_TESTS=1 -DSNOWHOUSE_RUN_TESTS=1 -D"SNOWHOUSE_CXX_STANDARD=C++$cxxstandard" "$SRCDIR" || exit
cmake --build . || exit