Skip to content

Commit

Permalink
CMake: use a dedicated variable to hold a path to the CFS source folder
Browse files Browse the repository at this point in the history
This is needed when CFE's root CMakeLists.txt is not the highest level
CMakeLists.txt in the project.
  • Loading branch information
stanislaw committed Feb 20, 2020
1 parent 5802d22 commit 8ee7c02
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ set(CMAKE_LEGACY_CYGWIN_WIN32 0)
# Add a path for any locally-supplied CMake modules
# These would typically be a part of any custom PSPs in use.
# (this is not required, and the directory can be empty/nonexistent)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/../psp/cmake/Modules" ${CMAKE_MODULE_PATH})
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../psp/cmake/Modules" ${CMAKE_MODULE_PATH})

# The minimum CMake version is chosen because 2.6.4 is what is
# included by default with RHEL/Centos 5.x
Expand All @@ -59,7 +59,8 @@ cmake_minimum_required(VERSION 2.6.4)
# that the subdirectories will at least use the "C" language, so
# indicate that now. Doing this early initializes the CFLAGS
# so they won't change later.
project(CFETOP C)
# Note: this line defines the CFE_SOURCE_DIR variable.
project(CFE C)

# Allow unit tests to be added by any recipe
enable_testing()
Expand Down
20 changes: 10 additions & 10 deletions cmake/mission_build.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function(initialize_globals)
# this is the parent (mission) build and variable values must be determined
# Obtain the "real" top-level source directory and set it in parent scope
if (NOT DEFINED MISSION_SOURCE_DIR)
get_filename_component(MISSION_SOURCE_DIR "${CMAKE_SOURCE_DIR}/.." ABSOLUTE)
get_filename_component(MISSION_SOURCE_DIR "${CFE_SOURCE_DIR}/.." ABSOLUTE)
set(MISSION_SOURCE_DIR ${MISSION_SOURCE_DIR} CACHE PATH "Top level mission source directory")
endif(NOT DEFINED MISSION_SOURCE_DIR)

Expand Down Expand Up @@ -211,13 +211,13 @@ function(prepare)
file(WRITE "${CMAKE_BINARY_DIR}/doc/mission-content.doxyfile"
${MISSION_DOXYFILE_USER_CONTENT})

configure_file("${CMAKE_SOURCE_DIR}/cmake/cfe-common.doxyfile.in"
configure_file("${CFE_SOURCE_DIR}/cmake/cfe-common.doxyfile.in"
"${CMAKE_BINARY_DIR}/doc/cfe-common.doxyfile")

configure_file("${CMAKE_SOURCE_DIR}/cmake/osal-common.doxyfile.in"
configure_file("${CFE_SOURCE_DIR}/cmake/osal-common.doxyfile.in"
"${CMAKE_BINARY_DIR}/doc/osal-common.doxyfile")

configure_file("${CMAKE_SOURCE_DIR}/cmake/mission-detaildesign.doxyfile.in"
configure_file("${CFE_SOURCE_DIR}/cmake/mission-detaildesign.doxyfile.in"
"${CMAKE_BINARY_DIR}/doc/mission-detaildesign.doxyfile")

# The user guide should include the doxygen from the _public_ API files from CFE + OSAL
Expand Down Expand Up @@ -247,10 +247,10 @@ function(prepare)
set(OSALGUIDE_PREDEFINED
"MESSAGE_FORMAT_IS_CCSDS")

configure_file("${CMAKE_SOURCE_DIR}/cmake/cfe-usersguide.doxyfile.in"
configure_file("${CFE_SOURCE_DIR}/cmake/cfe-usersguide.doxyfile.in"
"${CMAKE_BINARY_DIR}/doc/cfe-usersguide.doxyfile")

configure_file("${CMAKE_SOURCE_DIR}/cmake/osalguide.doxyfile.in"
configure_file("${CFE_SOURCE_DIR}/cmake/osalguide.doxyfile.in"
"${CMAKE_BINARY_DIR}/doc/osalguide.doxyfile")

add_custom_target(mission-doc
Expand Down Expand Up @@ -302,7 +302,7 @@ function(prepare)
add_custom_target(mission-version
COMMAND
${CMAKE_COMMAND} -D BIN=${CMAKE_BINARY_DIR}
-P ${CMAKE_SOURCE_DIR}/cmake/version.cmake
-P ${CFE_SOURCE_DIR}/cmake/version.cmake
WORKING_DIRECTORY
${CMAKE_SOURCE_DIR}
)
Expand Down Expand Up @@ -345,8 +345,8 @@ function(process_arch TARGETSYSTEM)
# Find the toolchain file - allow a file in the mission defs dir to supercede one in the compile dir
if (EXISTS ${MISSION_DEFS}/toolchain-${CURRSYS}.cmake)
set(TOOLCHAIN_FILE ${MISSION_DEFS}/toolchain-${CURRSYS}.cmake)
elseif(EXISTS ${CMAKE_SOURCE_DIR}/cmake/toolchain-${CURRSYS}.cmake)
set(TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/toolchain-${CURRSYS}.cmake)
elseif(EXISTS ${CFE_SOURCE_DIR}/cmake/toolchain-${CURRSYS}.cmake)
set(TOOLCHAIN_FILE ${CFE_SOURCE_DIR}/cmake/toolchain-${CURRSYS}.cmake)
else()
message(FATAL_ERROR "Unable to find toolchain file for ${CURRSYS}")
endif()
Expand All @@ -365,7 +365,7 @@ function(process_arch TARGETSYSTEM)
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
${SELECTED_TOOLCHAIN_FILE}
${CMAKE_SOURCE_DIR}
${CFE_SOURCE_DIR}
WORKING_DIRECTORY
"${ARCH_BINARY_DIR}"
RESULT_VARIABLE
Expand Down

0 comments on commit 8ee7c02

Please sign in to comment.