Skip to content

Commit

Permalink
Fixed build issues when building in "getting_started" dir (#662)
Browse files Browse the repository at this point in the history
* Fixed build issues when building in "getting_started" dir

Fixes #646

Signed-off-by: The MathWorks, Inc. <alchrist@mathworks.com>

* Made changes requested by reviewer
  • Loading branch information
achristoforides committed Apr 27, 2022
1 parent 7364c9a commit 47a3f92
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions doc/src/examples/getting_started/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
cmake_minimum_required(VERSION 3.17)

# [proj-begin]
project(CppMicroServicesGettingStarted)

Expand All @@ -6,6 +8,19 @@ find_package(CppMicroServices REQUIRED)

include(GenerateExportHeader)

# Detect "local" build (build from getting started directory)
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
# Set binary and library output directories
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")

set(BUILD_SHARED_LIBS ON CACHE BOOL "Build shared libraries")
set(US_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})

set(CMAKE_ENABLE_EXPORTS ON)
endif()

# [interface-begin]
#=========================================================
# A library providing the ServiceTime interface
Expand Down Expand Up @@ -127,8 +142,8 @@ if(NOT BUILD_SHARED_LIBS)
usFunctionGetResourceSource(TARGET GettingStarted OUT _srcs)
endif()

add_executable(GettingStarted ${_srcs})

add_executable(GettingStarted)
target_sources(GettingStarted PRIVATE ${_srcs})
target_link_libraries(GettingStarted CppMicroServices)

if(NOT BUILD_SHARED_LIBS)
Expand Down

0 comments on commit 47a3f92

Please sign in to comment.