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

libsdptransform: support additional CMake build options #125

Closed
Closed
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
38 changes: 29 additions & 9 deletions deps/libsdptransform/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ set(CMAKE_CXX_EXTENSIONS OFF)
# For CMake < 3.1.
add_compile_options(-std=c++11)

subdirs(test readme-helper)

include_directories(${sdptransform_SOURCE_DIR}/include)

set(
SOURCE_FILES
src/grammar.cpp
Expand All @@ -22,11 +18,35 @@ set(

set(
HEADER_FILES
include/sdptransform.hpp
include/json.hpp
${sdptransform_BINARY_DIR}/include/sdptransform.hpp
)

add_library(sdptransform STATIC ${SOURCE_FILES} ${HEADER_FILES})

install(TARGETS sdptransform DESTINATION lib)
option(BUILD_TESTS "Build tests" ON)
if(BUILD_TESTS)
add_subdirectory(test)
endif()

option(BUILD_README_HELPER "Build readme-helper" ON)
if(BUILD_README_HELPER)
add_subdirectory(readme-helper)
endif()

option(BUILD_SHARED_LIBS "Build shared library" OFF)
add_library(sdptransform ${SOURCE_FILES})

target_include_directories(sdptransform PUBLIC ${sdptransform_BINARY_DIR}/include)

option(USE_EXTERNAL_JSON "Use external nlohmann_json instead of bundled" OFF)
if(USE_EXTERNAL_JSON)
find_package(nlohmann_json REQUIRED)
target_link_libraries(sdptransform nlohmann_json::nlohmann_json)
set(JSON_HPP_LOCATION "<nlohmann/json.hpp>")
else()
target_include_directories(sdptransform PUBLIC thirdparty)
list(APPEND HEADER_FILES thirdparty/json.hpp)
set(JSON_HPP_LOCATION "\"json.hpp\"")
endif()
configure_file(include/sdptransform.hpp.in include/sdptransform.hpp)

install(TARGETS sdptransform)
install(FILES ${HEADER_FILES} DESTINATION include/sdptransform)
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef SDPTRANSFORM_HPP
#define SDPTRANSFORM_HPP

#include "json.hpp"
#include @JSON_HPP_LOCATION@
#include <string>
#include <vector>
#include <map>
Expand Down
2 changes: 0 additions & 2 deletions deps/libsdptransform/readme-helper/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
include_directories(${sdptransform_SOURCE_DIR}/include)

set(
SOURCE_FILES
readme.cpp
Expand Down
4 changes: 1 addition & 3 deletions deps/libsdptransform/test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
include_directories(${sdptransform_SOURCE_DIR}/include)
include_directories(include)

set(
SOURCE_FILES
tests.cpp
Expand All @@ -14,6 +11,7 @@ set(
)

add_executable(test_sdptransform ${SOURCE_FILES} ${HEADER_FILES})
target_include_directories(test_sdptransform PRIVATE include)

if(${CMAKE_SYSTEM_NAME} STREQUAL "Android")
target_link_libraries(test_sdptransform sdptransform android log)
Expand Down