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

Add FLATCC_BUILD_INTO_SOURCE_DIR cmake option #306

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
29 changes: 20 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ option(FLATCC_RTONLY "enable build of runtime library only" OFF)
# cmake -DBUILD_SHARED_LIBS=on can override.
option(FLATCC_INSTALL "enable install targets" OFF)

# Place built targets into the source tree, not under the binary directory. This
# does not affect the install behavior.
option(FLATCC_BUILD_INTO_SOURCE_DIR
"place built targets under the source directory" ON)

# Use with debug build with testing enabled only. Enables generation
# of coverage information during build and run. Adds target "coverage"
# which collects data and makes HTML report in build directory
Expand Down Expand Up @@ -163,10 +168,13 @@ else()
set(lib_dir ${FLATCC_INSTALL_LIB})
endif()

# The folder of this directory, as apposed to CMAKE_BINARY_DIR
# which would usually be the build/Release and build/Debug paths
set (dist_dir "${PROJECT_SOURCE_DIR}")
# set (dist_dir "${CMAKE_BINARY_DIR}")
if (FLATCC_BUILD_INTO_SOURCE_DIR)
# The folder of this directory, as apposed to CMAKE_BINARY_DIR
# which would usually be the build/Release and build/Debug paths
set (dist_dir "${PROJECT_SOURCE_DIR}")
else()
set (dist_dir "${CMAKE_BINARY_DIR}")
endif()

message(STATUS "dist install dir ${dist_dir}")
message(STATUS "lib install dir ${dist_dir}/${lib_dir}")
Expand Down Expand Up @@ -329,12 +337,15 @@ if (GCC_VERSION)
endif()
message(STATUS "Configured C_FLAGS: ${CMAKE_C_FLAGS}")

set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/${lib_dir})
set(LIBRARY_OUTPUT_PATH ${dist_dir}/${lib_dir})

set(CMAKE_DEBUG_POSTFIX "_d")

if (CMAKE_BUILD_TYPE MATCHES "Debug")
set(CMAKE_EXECUTABLE_SUFFIX "_d${CMAKE_EXECUTABLE_SUFFIX}")
if (FLATCC_BUILD_INTO_SOURCE_DIR)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also let me know if you'd rather that I folded this into the if (FLATCC_BUILD_INTO_SOURCE_DIR) on line 171 to consolidate the logic.

# Release and debug target artifacts need to coexist in the same directory.
# Add a suffix to debug libraries and executables.
set(CMAKE_DEBUG_POSTFIX "_d")
if (CMAKE_BUILD_TYPE MATCHES "Debug")
set(CMAKE_EXECUTABLE_SUFFIX "_d${CMAKE_EXECUTABLE_SUFFIX}")
endif()
endif()


Expand Down