Skip to content

Commit

Permalink
RelWithDebInfo (#1702)
Browse files Browse the repository at this point in the history
  • Loading branch information
casperdcl committed Feb 12, 2024
1 parent 4695bc8 commit 78f6e07
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jobs:
- name: build cil
run: |
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DCONDA_BUILD=ON -DCMAKE_INSTALL_PREFIX="$CONDA_PREFIX"
cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCONDA_BUILD=ON -DCMAKE_INSTALL_PREFIX="$CONDA_PREFIX"
cmake --build . --target install
- name: checkout docs
uses: actions/checkout@v4
Expand Down
14 changes: 8 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,22 @@ project (cil LANGUAGES CXX)
# If APPLE don't use @rpath
if (APPLE)
option(SHARED_LIBS_ABS_PATH "Force shared libraries to be installed with absolute paths (as opposed to rpaths)" ON)
mark_as_advanced( SHARED_LIBS_ABS_PATH )
mark_as_advanced( SHARED_LIBS_ABS_PATH )
if (SHARED_LIBS_ABS_PATH)
# Set install_name_dir as the absolute path to install_prefix/lib
GET_FILENAME_COMPONENT(CMAKE_INSTALL_NAME_DIR ${CMAKE_INSTALL_PREFIX}/lib REALPATH)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
endif(SHARED_LIBS_ABS_PATH)
endif(APPLE)

set(CMAKE_BUILD_TYPE "Release")
if(NOT DEFINED CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "RelWithDebInfo")
endif()


# CIL version TAG is determined by git describe as for the conda package
# variable GIT_DESCRIBE_TAG
# https://docs.conda.io/projects/conda-build/en/stable/resources/define-metadata.html#templating-with-jinja
# variable GIT_DESCRIBE_TAG
# https://docs.conda.io/projects/conda-build/en/stable/resources/define-metadata.html#templating-with-jinja
# https://stackoverflow.com/questions/38919840/get-package-version-for-conda-meta-yaml-from-source-file

find_package(Git REQUIRED)
Expand All @@ -50,7 +52,7 @@ find_package(Python COMPONENTS Interpreter REQUIRED)

if (Python_FOUND)
execute_process(COMMAND "${Python_EXECUTABLE}" ${CMAKE_CURRENT_SOURCE_DIR}/Wrappers/Python/CMake/parse_git_describe.py "${GIT_EXECUTABLE}"
RESULT_VARIABLE worked
RESULT_VARIABLE worked
OUTPUT_VARIABLE CIL_VERSION
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_STRIP_TRAILING_WHITESPACE)
Expand All @@ -59,7 +61,7 @@ if (Python_FOUND)
else()
string(REPLACE " " ";" CIL_VERSION ${CIL_VERSION})
list(LENGTH CIL_VERSION CIL_version_len)

list(GET CIL_VERSION 0 CIL_VERSION_MAJOR)
list(GET CIL_VERSION 1 CIL_VERSION_MINOR)
list(GET CIL_VERSION 2 CIL_VERSION_PATCH)
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ ENV TENSORBOARD_PROXY_URL=/user-redirect/proxy/6006/
# build & install CIL
COPY --chown="${NB_USER}" . src
RUN mkdir build && cd build \
&& cmake ../src -DCMAKE_BUILD_TYPE="Release" -DCONDA_BUILD=ON -DCMAKE_INSTALL_PREFIX="${CONDA_DIR}" \
&& cmake ../src -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCONDA_BUILD=ON -DCMAKE_INSTALL_PREFIX="${CONDA_DIR}" \
&& cmake --build . --target install \
&& cd .. && rm -rf src build \
&& fix-permissions "${CONDA_DIR}" /home/${NB_USER}
26 changes: 14 additions & 12 deletions Wrappers/Python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ option (BUILD_PYTHON_WRAPPER "Build Python Wrapper" ON)

if (BUILD_PYTHON_WRAPPER)
find_package(PythonInterp REQUIRED)

#set(PYTHON_DEST_DIR "" CACHE PATH "Directory of the Python wrappers")
if (PYTHON_DEST_DIR)
set(PYTHON_DEST "${PYTHON_DEST_DIR}")
else()
else()
message(STATUS "python version ${PYTHON_DEST}")
execute_process(COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/CMake/sp_dir.py
execute_process(COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/CMake/sp_dir.py
OUTPUT_VARIABLE SP_DIR)
# remove trailing newline
# remove trailing newline
string(REGEX REPLACE "\n$" "" PYTHON_DEST ${SP_DIR})
# append default site-packages
set(PYTHON_DEST "${PYTHON_DEST}/site-packages")
Expand All @@ -43,8 +43,10 @@ if (BUILD_PYTHON_WRAPPER)

message("CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}")

set(CMAKE_BUILD_TYPE "Release")

if(NOT DEFINED)
set(CMAKE_BUILD_TYPE "RelWithDebInfo")
endif()

find_package(PythonLibs)
if (PYTHONINTERP_FOUND)
message(STATUS "Found PYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}")
Expand All @@ -60,7 +62,7 @@ if (BUILD_PYTHON_WRAPPER)
set(SETUP_PY "${CMAKE_CURRENT_SOURCE_DIR}/setup.py")
set(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/timestamp")
file(GLOB_RECURSE DEPS ${CMAKE_CURRENT_SOURCE_DIR}/cil/*.py )

# adds the CIL_VERSION to the setup.py
if (EXISTS ${SETUP_PY})
file(REMOVE ${SETUP_PY})
Expand All @@ -77,21 +79,21 @@ if (BUILD_PYTHON_WRAPPER)
# add to add_custom_command DEPENDS the list of python files of the project.
# as a hack I remove ${OUTPUT}. This should trigger the new build.
file( REMOVE ${OUTPUT} )

add_custom_target(pythonsetup ALL
COMMAND ${CMAKE_COMMAND} -E env ${PYTHON_EXECUTABLE} -m pip install . -t ${PYTHON_DEST} --upgrade
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND ${CMAKE_COMMAND} -E touch ${OUTPUT}
DEPENDS cilacc)

# install the data if not a conda build. With conda the data is in the dependency package cil-data
if (NOT CONDA_BUILD)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data/ DESTINATION ${CMAKE_INSTALL_PREFIX}/share/cil)
endif()


add_custom_target(PythonWrapper ALL DEPENDS pythonsetup)

endif()

endif()
10 changes: 5 additions & 5 deletions recipe/bld.bat
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
REM -*- coding: utf-8 -*-
REM Copyright 2019 United Kingdom Research and Innovation
REM Copyright 2019 The University of Manchester

REM Licensed under the Apache License, Version 2.0 (the "License");
REM you may not use this file except in compliance with the License.
REM You may obtain a copy of the License at

REM http://www.apache.org/licenses/LICENSE-2.0

REM Unless required by applicable law or agreed to in writing, software
REM distributed under the License is distributed on an "AS IS" BASIS,
REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
REM See the License for the specific language governing permissions and
REM limitations under the License.

REM Authors:
REM CIL Developers, listed at: https://github.com/TomographicImaging/CIL/blob/master/NOTICE.txt

Expand All @@ -22,7 +22,7 @@ ROBOCOPY /E "%RECIPE_DIR%\.." "%SRC_DIR%" /XD .git /XD Wrappers\Python\build
mkdir "%SRC_DIR%\build_framework"

cd "%SRC_DIR%\build_framework"
cmake -G "NMake Makefiles" %RECIPE_DIR%\..\ -DCONDA_BUILD=ON -DCMAKE_BUILD_TYPE="Release" -DLIBRARY_LIB=%CONDA_PREFIX%\lib -DLIBRARY_INC=%CONDA_PREFIX% -DCMAKE_INSTALL_PREFIX=%PREFIX%
cmake -G "NMake Makefiles" %RECIPE_DIR%\..\ -DCONDA_BUILD=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -DLIBRARY_LIB=%CONDA_PREFIX%\lib -DLIBRARY_INC=%CONDA_PREFIX% -DCMAKE_INSTALL_PREFIX=%PREFIX%
if errorlevel 1 exit 1

cmake --build . --target install --config Release
Expand Down
2 changes: 1 addition & 1 deletion recipe/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fi

cmake ${RECIPE_DIR}/../ $extra_args \
-DCONDA_BUILD=ON \
-DCMAKE_BUILD_TYPE="Release" \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DLIBRARY_LIB=$CONDA_PREFIX/lib \
-DLIBRARY_INC=$CONDA_PREFIX/include \
-DCMAKE_INSTALL_PREFIX=$PREFIX \
Expand Down
18 changes: 9 additions & 9 deletions src/Core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@

set (CMAKE_CXX_STANDARD 11)
set (CMAKE_CXX_STANDARD_REQUIRED ON)
set (CMAKE_BUILD_TYPE Release)
if(NOT DEFINED CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE RelWithDebInfo)
endif()

message ("OpenMP_CXX_FLAGS ${OpenMP_CXX_FLAGS}")
find_package(OpenMP REQUIRED)
Expand All @@ -41,7 +43,7 @@ message("CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS}")
message("CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS}")
message("CMAKE_STATIC_LINKER_FLAGS ${CMAKE_STATIC_LINKER_FLAGS}")

if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.9.0")
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.9.0")
set (OpenMP_EXE_LINKER_FLAGS OpenMP::OpenMP_CXX)
else()
message(WARNING "Your CMake version is old. OpenMP linking flags might be incorrect.")
Expand Down Expand Up @@ -107,25 +109,23 @@ endif()
# RUNTIME DESTINATION bin
# LIBRARY DESTINATION lib
# ARCHIVE DESTINATION lib
# CONFIGURATIONS ${CMAKE_BUILD_TYPE}
# CONFIGURATIONS ${CMAKE_BUILD_TYPE}
# )

if (UNIX)
message ("I'd install into ${CMAKE_INSTALL_PREFIX}/lib")
install(TARGETS cilacc
LIBRARY DESTINATION lib
CONFIGURATIONS ${CMAKE_BUILD_TYPE}
CONFIGURATIONS ${CMAKE_BUILD_TYPE}
)
elseif(WIN32)
message ("I'd install into ${CMAKE_INSTALL_PREFIX} lib bin")
install(TARGETS cilacc
install(TARGETS cilacc
RUNTIME DESTINATION Library/bin
ARCHIVE DESTINATION lib
CONFIGURATIONS ${CMAKE_BUILD_TYPE}
CONFIGURATIONS ${CMAKE_BUILD_TYPE}
)
endif()

install(DIRECTORY ${PROJECT_SOURCE_DIR}/src/Core/include/
DESTINATION ${CMAKE_INSTALL_PREFIX}/include/cil)


DESTINATION ${CMAKE_INSTALL_PREFIX}/include/cil)

0 comments on commit 78f6e07

Please sign in to comment.