Skip to content

Commit

Permalink
dfsg: cmake: drop the use of CMAKE_INSTALL_SUB_PATH
Browse files Browse the repository at this point in the history
Signed-off-by: You-Sheng Yang <vicamo.yang@canonical.com>
  • Loading branch information
vicamo committed Aug 30, 2023
1 parent 9d17ecd commit 5c58051
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 35 deletions.
47 changes: 24 additions & 23 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -256,13 +256,14 @@ set_target_properties(camhal PROPERTIES VERSION "0.0.0")

add_library(camhal_static STATIC ${LIBCAMHAL_SRCS})

if (NOT CAL_BUILD AND (NOT "${CMAKE_INSTALL_SUB_PATH}" STREQUAL ""))
set(CMAKE_SKIP_RPATH TRUE)
set_target_properties(camhal PROPERTIES LINK_FLAGS
"-Wl,-rpath,/usr/lib/${CMAKE_INSTALL_SUB_PATH}")
add_compile_definitions(SUB_CONFIG_PATH="${CMAKE_INSTALL_SUB_PATH}")
if(NOT DEFINED IPU_VER)
set(CAMHAL_NAME_SUFFIX "-ipu4")
elseif(${IPU_VER} STREQUAL ipu6)
set(CAMHAL_NAME_SUFFIX "")
else()
set(CAMHAL_NAME_SUFFIX "-${IPU_VER}")
endif()
set_target_properties(camhal_static PROPERTIES OUTPUT_NAME "camhal")
set_target_properties(camhal_static PROPERTIES OUTPUT_NAME camhal${CAMHAL_NAME_SUFFIX})

#---------------------------- Link settings ----------------------------
target_link_libraries(camhal ${CMAKE_DL_LIBS})
Expand Down Expand Up @@ -384,37 +385,37 @@ endif() #ENABLE_SANDBOXING
#--------------------------- Install settings ---------------------------
if (NOT CAL_BUILD)
# Install headers
if ("${CMAKE_INSTALL_SUB_PATH}" STREQUAL "")
install(DIRECTORY include/ DESTINATION include/libcamhal)
if (SUPPORT_LIVE_TUNING)
install(FILES modules/livetune/LiveTuning.h DESTINATION include/libcamhal/api)
endif() #SUPPORT_LIVE_TUNING
endif()
install(DIRECTORY include/ DESTINATION include/libcamhal)
if (SUPPORT_LIVE_TUNING)
install(FILES modules/livetune/LiveTuning.h DESTINATION include/libcamhal/api)
endif() #SUPPORT_LIVE_TUNING

# Install configure files, by default ipu4 is used
if(("${IPU_VER}" STREQUAL "") OR ("${IPU_VER}" STREQUAL "ipu4"))
message("Install camera configure files for ipu4")
install(DIRECTORY config/linux/ipu4/ DESTINATION share/defaults/etc/camera/${CMAKE_INSTALL_SUB_PATH})
if("${IPU_VER}" STREQUAL "")
set(CAMHAL_CFG_VARIANT ipu4)
else()
message("Install camera configure files for" ${IPU_VER})
install(DIRECTORY config/linux/${IPU_VER}/ DESTINATION share/defaults/etc/camera/${CMAKE_INSTALL_SUB_PATH})
set(CAMHAL_CFG_VARIANT ${IPU_VER})
endif()
message("Install camera configure files for ${CAMHAL_CFG_VARIANT}")
install(DIRECTORY config/linux/${CAMHAL_CFG_VARIANT}/ DESTINATION share/defaults/etc/camera/${CAMHAL_CFG_VARIANT})
add_definitions("-DCAMERA_DEFAULT_CFG_PATH=\"${CMAKE_INSTALL_PREFIX}/share/defaults/etc/camera/${CAMHAL_CFG_VARIANT}/\"")

# Install libraries
if (${CMAKE_VERSION} VERSION_LESS 3.11)
install(TARGETS camhal camhal_static
LIBRARY DESTINATION lib/${CMAKE_INSTALL_SUB_PATH}
ARCHIVE DESTINATION lib/${CMAKE_INSTALL_SUB_PATH}
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)
else()
install(TARGETS camhal camhal_static DESTINATION lib/${CMAKE_INSTALL_SUB_PATH})
install(TARGETS camhal camhal_static DESTINATION lib)
endif()
set_target_properties(camhal PROPERTIES OUTPUT_NAME camhal${CAMHAL_NAME_SUFFIX})

# Install package config file
configure_file(${PROJECT_SOURCE_DIR}/cmake/libcamhal.pc.cmakein
${PROJECT_SOURCE_DIR}/libcamhal.pc @ONLY)
install(FILES libcamhal.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/${CMAKE_INSTALL_SUB_PATH}/pkgconfig)
${PROJECT_SOURCE_DIR}/libcamhal${CAMHAL_NAME_SUFFIX}.pc @ONLY)
install(FILES libcamhal${CAMHAL_NAME_SUFFIX}.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)

endif() #NOT CAL_BUILD

Expand Down
4 changes: 1 addition & 3 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,14 @@ function build_target() {
-DBUILD_CAMHAL_TESTS=OFF \
-DUSE_PG_LITE_PIPE=ON \
-DCMAKE_INSTALL_PREFIX=$INSTALL_DIR/install \
-DCMAKE_INSTALL_SUB_PATH=$target ..
..

# make and install
make -j`nproc`
check_result $? "$FUNCNAME: $target"

make install
check_result $? "$FUNCNAME: $target"
standardize_pkg_config_path ${INSTALL_DIR}/install/lib/${target}/pkgconfig/libcamhal.pc
cd ..
}

Expand All @@ -124,7 +123,6 @@ function build_hal_adaptor() {

make install
check_result $? $FUNCNAME
standardize_pkg_config_path ${INSTALL_DIR}/install/lib/pkgconfig/hal_adaptor.pc
}

function build_icamerasrc() {
Expand Down
8 changes: 4 additions & 4 deletions cmake/libcamhal.pc.cmakein
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix}/@CMAKE_INSTALL_SUB_PATH@
libdir=${prefix}/lib/@CMAKE_INSTALL_SUB_PATH@
includedir=${prefix}/include/@CMAKE_INSTALL_SUB_PATH@/libcamhal
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include/libcamhal

Name: libcamhal
Description: Camera HAL Library
URL:
Version: @VERSION@
Libs: -L${libdir} -lcamhal
Libs: -L${libdir} -lcamhal@CAMHAL_NAME_SUFFIX@
Cflags: -I${includedir} -I${includedir}/api -I${includedir}/utils
4 changes: 0 additions & 4 deletions src/platformdata/PlatformData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1608,10 +1608,6 @@ camera_coordinate_system_t PlatformData::getActivePixelArray(int cameraId) {

string PlatformData::getCameraCfgPath() {
string cfgPath = string(CAMERA_DEFAULT_CFG_PATH);
#ifdef SUB_CONFIG_PATH
cfgPath += string(SUB_CONFIG_PATH);
cfgPath.append("/");
#endif

char* p = getenv("CAMERA_CFG_PATH");
return p ? string(p) : cfgPath;
Expand Down
4 changes: 3 additions & 1 deletion src/platformdata/PlatformData.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ namespace icamera {
#define MAX_CAMERA_NUMBER 100
// Temporarily using current path to save aiqd file for none CAL platforms.
#define CAMERA_CACHE_DIR "./"
#define CAMERA_DEFAULT_CFG_PATH "/usr/share/defaults/etc/camera/"
#if !defined(CAMERA_DEFAULT_CFG_PATH)
#error CAMERA_DEFAULT_CFG_PATH not defined.
#endif
#define CAMERA_GRAPH_DESCRIPTOR_FILE "gcss/graph_descriptor.xml"
#define CAMERA_GRAPH_SETTINGS_DIR "gcss/"
#endif
Expand Down

0 comments on commit 5c58051

Please sign in to comment.