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

Build instructions need improvement #10

Closed
dturner opened this issue Nov 6, 2017 · 6 comments
Closed

Build instructions need improvement #10

dturner opened this issue Nov 6, 2017 · 6 comments

Comments

@dturner
Copy link
Collaborator

dturner commented Nov 6, 2017

We are asking the user to write their own cmake directives to build Oboe (or rather copy pasting the guide example). This mean we are not controlling the way Oboe is build. I would rather propose to change the Oboe CMakefile.txt and have client include it.
Such as (note that I am using more recent (and powerful) cmake api than what the current CMakeList.txt):

# CMakeLists.txt at the root of Oboe

# Note for Phil&Don: GLOB usage is discouraged as
#       if new source files are added, they will NOT be compiled
#       (GLOB is extended on cmake call, not make)
file (GLOB_RECURSE OBOE_SOURCES src/*.cpp) # note that .h should not be included
add_library(oboe STATIC ${OBOE_SOURCES})

# I would recommend to do:
# add_library(oboe STATIC src/fifo/FifoControllerBase.cpp
#                         src/fifo/FifoController.cpp
#                         src/fifo/FifoBuffer.cpp
#                         src/fifo/FifoControllerIndirect.cpp
#                         src/aaudio/OboeStreamAAudio.cpp
#                         src/aaudio/AAudioLoader.cpp
#                         src/common/OboeStream.cpp
#                         src/common/OboeStreamBuilder.cpp
#                         src/common/OboeUtilities.cpp
#                         src/common/OboeLatencyTuner.cpp
#                         src/opensles/OpenSLESUtilities.cpp
#                         src/opensles/OboeStreamOpenSLES.cpp
#                         src/opensles/OboeStreamBuffered.cpp
# )


# Mark the oboes headers as system for the client,
# that way if the client has a different set of warning he should not see failures
target_include_directories(oboe PRIVATE src include)
target_include_directories(oboe SYSTEM INTERFACE include)

target_compile_options(oboe PRIVATE -std=c++11 # Change to PUBLIC if using c++11 in public headers
                            PRIVATE -Wall -Wextra
                            PRIVATE "$<$<CONFIG:DEBUG>:-Werror>")
#                                   ^ Example: Only a debug build will fail from warnings

target_link_libraries(oboe PRIVATE log OpenSLES)


# Client just have to do:
# add_subdirectory(path/to/oboe)
# target_link_libraries(native-lib PRIVATE oboe)

# NOTE: it might be better to use cmake "ExternalProject" command

Thanks to krocard

@dturner
Copy link
Collaborator Author

dturner commented Dec 4, 2017

I looked into using ExternalProject_Add and you have to add a line to your CMakeLists.txt to include that CMake module. Using add_subdirectory seems to work pretty well and minimises the work required to add Oboe to an existing project.

@dturner
Copy link
Collaborator Author

dturner commented Dec 4, 2017

One question though: If I use -Wextra I get a lot of "unused parameter" warnings which are treated as errors causing the build to fail. It's obvious why these errors are generated - because the client app isn't using all the oboe functions. Is -Wno-unused-variable the way to handle this gracefully?

@dturner
Copy link
Collaborator Author

dturner commented Dec 8, 2017

Fixed in e6c1c74

@dturner dturner closed this as completed Dec 8, 2017
@pblandford
Copy link

That -std=c++11 switch is actually essential (at least I couldn't get it to build without it), but the build instructions don't mention it.

@dturner
Copy link
Collaborator Author

dturner commented Jun 20, 2018

The -std=c++11 is in Oboe's own CMakeLists.txt so to build it you just need to use add_subdirectory from your own CMakeLists.txt as per these instructions. Does that work for you? Does something else need updating?

@sdenheyer
Copy link

Hi - very new to native & Oboe. I'm trying to implement Oboe into a pre-existing app. After doing all the pre-requisites for adding native, and creating a CMakeLists.txt as directed in the Oboe getting started docs.

My project is now populated with "aaudio", "common", "fifo", so it's partially working.

But my #include <oboe/Oboe.h> is not working - it's not picking up that file at all. I'm not missing the "include_directories" line in CmakeLists which is where Oboe.h resides.

I've tried a few things with CMake, and I've tried starting a fresh Native project and adding Oboe to that, but nothing works.

What am I doing wrong?

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants