diff --git a/cmake/features.cmake b/cmake/features.cmake index 91d30c4a6ac4fc..46168884643104 100644 --- a/cmake/features.cmake +++ b/cmake/features.cmake @@ -50,3 +50,7 @@ ie_option (ENABLE_PROFILING_ITT "Build with ITT tracing. Optionally configure pr ie_option (ENABLE_DOCS "build docs using Doxygen" OFF) ie_dependent_option (ENABLE_FASTER_BUILD "Enable build features (PCH, UNITY) to speed up build time" OFF "CMAKE_VERSION VERSION_GREATER_EQUAL 3.16" OFF) + +# Type of build, we add this as an explicit option to default it to ON +# FIXME: Ah this moment setting this to OFF will only build ngraph a static library +ie_option (BUILD_SHARED_LIBS, "Build as a shared library" ON) diff --git a/ngraph/CMakeLists.txt b/ngraph/CMakeLists.txt index 928143898c00ad..29a6f47810eea9 100644 --- a/ngraph/CMakeLists.txt +++ b/ngraph/CMakeLists.txt @@ -124,7 +124,6 @@ option(NGRAPH_ADDRESS_SANITIZER_ENABLE "Compiles and links with Address Sanitize option(NGRAPH_THREAD_SANITIZER_ENABLE "Compiles and links with Thread Sanitizer" FALSE) option(NGRAPH_UB_SANITIZER_ENABLE "Compiles and links with Undefined Behavior Sanitizer" FALSE) option(NGRAPH_USE_PROTOBUF_LITE "Compiles and links with protobuf-lite" FALSE) -option(NGRAPH_STATIC_LIBRARY "Compiles ngraph as a static library" FALSE) if (NGRAPH_ONNX_IMPORT_ENABLE) option(NGRAPH_USE_SYSTEM_PROTOBUF "Use system provided Protobuf shared object" FALSE) @@ -162,7 +161,6 @@ NORMALIZE_BOOL(NGRAPH_ADDRESS_SANITIZER_ENABLE) NORMALIZE_BOOL(NGRAPH_THREAD_SANITIZER_ENABLE) NORMALIZE_BOOL(NGRAPH_UB_SANITIZER_ENABLE) NORMALIZE_BOOL(NGRAPH_USE_PROTOBUF_LITE) -NORMALIZE_BOOL(NGRAPH_STATIC_LIBRARY) message(STATUS "NGRAPH_ADDRESS_SANITIZER_ENABLE: ${NGRAPH_ADDRESS_SANITIZER_ENABLE}") message(STATUS "NGRAPH_CODE_COVERAGE_ENABLE: ${NGRAPH_CODE_COVERAGE_ENABLE}") @@ -181,7 +179,6 @@ message(STATUS "NGRAPH_UB_SANITIZER_ENABLE: ${NGRAPH_UB_SANITIZER_ENAB message(STATUS "NGRAPH_USE_PROTOBUF_LITE: ${NGRAPH_USE_PROTOBUF_LITE}") message(STATUS "NGRAPH_UNIT_TEST_ENABLE: ${NGRAPH_UNIT_TEST_ENABLE}") message(STATUS "NGRAPH_WARNINGS_AS_ERRORS: ${NGRAPH_WARNINGS_AS_ERRORS}") -message(STATUS "NGRAPH_STATIC_LIBRARY: ${NGRAPH_STATIC_LIBRARY}") set(NGRAPH_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD ${NGRAPH_CXX_STANDARD}) @@ -483,7 +480,7 @@ if (NGRAPH_EXPORT_TARGETS_ENABLE) set(NGRAPH_TARGETS_FILE "${CMAKE_CURRENT_BINARY_DIR}/ngraphTargets.cmake") export(TARGETS ngraph NAMESPACE ngraph:: FILE "${NGRAPH_TARGETS_FILE}") - if(NOT NGRAPH_STATIC_LIBRARY) + if(BUILD_SHARED_LIBS) install(EXPORT ngraphTargets FILE ngraphTargets.cmake NAMESPACE ngraph:: diff --git a/ngraph/core/CMakeLists.txt b/ngraph/core/CMakeLists.txt index d7fcbd25e4256e..f9297700bfc042 100644 --- a/ngraph/core/CMakeLists.txt +++ b/ngraph/core/CMakeLists.txt @@ -33,13 +33,9 @@ source_group("include" FILES ${PUBLIC_HEADERS}) configure_file(include/ngraph/version.in.hpp include/ngraph/version.hpp) -if (NGRAPH_STATIC_LIBRARY) - # Create static library - add_library(ngraph STATIC ${LIBRARY_SRC} ${PUBLIC_HEADERS}) -else() - # Create shared library - add_library(ngraph SHARED ${LIBRARY_SRC} ${PUBLIC_HEADERS}) -endif() +# Create static or shared library depending on BUILD_SHARED_LIBS +add_library(ngraph ${LIBRARY_SRC} ${PUBLIC_HEADERS}) + if(COMMAND ie_faster_build) ie_faster_build(ngraph @@ -75,7 +71,7 @@ if(NGRAPH_LIB_VERSIONING_ENABLE) SOVERSION ${NGRAPH_API_VERSION}) endif() target_compile_definitions(ngraph PUBLIC NGRAPH_VERSION="${NGRAPH_VERSION}") -if(NGRAPH_STATIC_LIBRARY) +if(NOT BUILD_SHARED_LIBS) target_compile_definitions(ngraph PUBLIC NGRAPH_STATIC_LIBRARY) endif()