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

[WIP] Some modernization and this should fix #68, #29 #89

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Generated Files
config/lcio.properties
doc/index.html
doc/lcio.xml
pom.xml
src/aid/EVENT/LCIO.aid
src/cpp/include/lcio.h
src/cpp/include/pre-generated/EVENT/LCIO.h
src/latex/manual/manual.tex

# Default folder
/build
/bin
92 changes: 58 additions & 34 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,41 @@
# cmake file for building LCIO
# @author Frank Gaede, DESY
# @author Jan Engels, DESY
CMAKE_MINIMUM_REQUIRED( VERSION 2.8 FATAL_ERROR )
cmake_minimum_required( VERSION 3.0 FATAL_ERROR )
########################################################



# project name
PROJECT( LCIO )


project( LCIO )
# project version
SET( LCIO_VERSION_MAJOR 2 )
SET( LCIO_VERSION_MINOR 14 )
SET( LCIO_VERSION_PATCH 2 )

# lcio.jar
option( INSTALL_JAR "Set to OFF to skip build/install lcio.jar" OFF )
option( BUILD_APPS "Set to OFF to skip build/install of apps" ON )
# allow C++ only builds
option( LCIO_GENERATE_HEADERS "Set to OFF to use pre-generated headers (no java needed)" OFF)
option( BUILD_ROOTDICT "Set to ON to build ROOT dictionary" OFF )
option( BUILD_FORTRAN "Set to OFF to skip build/install Fortran codes" ON )
option( BUILD_F77_TESTJOBS "Set to ON to build LCIO F77 testjobs" OFF )
option( INSTALL_DOC "Set to OFF to skip build/install Documentation" OFF )
option( BUILD_LCIO_EXAMPLES "Set to ON to build LCIO examples" ON )
option( INSTALL_PYTHON "Set to ON to install python codes" ON)

include(CheckLanguage)

if(BUILD_FORTRAN OR BUILD_F77_TESTJOBS)
check_language(Fortran)
if(CMAKE_Fortran_COMPILER)
enable_language(Fortran)
else()
message(STATUS "No Fortran support !!!")
set(BUILD_FORTRAN OFF)
set(BUILD_F77_TESTJOBS OFF)
endif()
endif()

### set correct LCIO version in relevant files ############################

configure_file (
Expand Down Expand Up @@ -66,21 +87,17 @@ IF( NOT CMAKE_CXX_STANDARD )
ENDIF()
SET( CMAKE_CXX_STANDARD_REQUIRED ON )

# lcio.jar
OPTION( INSTALL_JAR "Set to OFF to skip build/install lcio.jar" OFF )

# allow C++ only builds
OPTION( LCIO_GENERATE_HEADERS "Set to OFF to use pre-generated headers (no java needed)" OFF)

IF( INSTALL_JAR )
INSTALL( CODE "EXECUTE_PROCESS( COMMAND ${CMAKE_BUILD_TOOL} jar)" )
INSTALL( FILES "${PROJECT_SOURCE_DIR}/lib/lcio.jar" DESTINATION lib )# OPTIONAL )
ENDIF()


# install python stuff (for out-of-source-build)
INSTALL( DIRECTORY "${PROJECT_SOURCE_DIR}/src/python/" DESTINATION python )
INSTALL( DIRECTORY "${PROJECT_SOURCE_DIR}/examples/python/" DESTINATION python/examples )
if( INSTALL_PYTHON )
install( DIRECTORY "${PROJECT_SOURCE_DIR}/src/python/" DESTINATION python )
install( DIRECTORY "${PROJECT_SOURCE_DIR}/examples/python/" DESTINATION python/examples )
endif()


# JAVA (needed to generate c++ headers)
Expand All @@ -94,10 +111,16 @@ endif()


# ROOT
OPTION( BUILD_ROOTDICT "Set to ON to build ROOT dictionary" OFF )
IF( BUILD_ROOTDICT )
FIND_PACKAGE( ROOT 6.04 REQUIRED ) # look for ROOT versions >= 5.27.06
ENDIF()
if( BUILD_ROOTDICT )
find_package( ROOT 6.04 REQUIRED )
##Need to check if ROOT has been compiled with other CXX_STANDARD
get_property(ROOT_CXX_STANDARD TARGET ROOT::Core PROPERTY INTERFACE_COMPILE_FEATURES)
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this is a good idea to overwrite the CXX standard here depending on ROOT. This should be up to the user to make sure things are compatible.

Copy link
Contributor Author

@flagarde flagarde Jul 22, 2020

Choose a reason for hiding this comment

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

If we don't do this it cannot compile.. other option is to just compile thé Root code with such property. Like this the project Can still be cpp11 but the root code that must follow root properties can be built

if(${ROOT_CXX_STANDARD} STREQUAL "cxx_std_17")
set( CMAKE_CXX_STANDARD 17 )
elseif(${ROOT_CXX_STANDARD} STREQUAL "cxx_std_20")
set( CMAKE_CXX_STANDARD 20 )
endif()
endif()


# DCAP
Expand All @@ -123,11 +146,11 @@ ENDIF()


# UNIX SHELL (needed for calling LCIO_ENV_INIT script)
FIND_PROGRAM( SH sh ${CYGWIN_INSTALL_PATH}/bin /bin /usr/bin /usr/local/bin /sbin )
MARK_AS_ADVANCED( SH )
IF( NOT SH )
MESSAGE( FATAL_ERROR "unix shell not found" )
ENDIF()
#FIND_PROGRAM( SH sh ${CYGWIN_INSTALL_PATH}/bin /bin /usr/bin /usr/local/bin /sbin )
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did you remove this? It is required

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't find anywhere where you use the sh program

#MARK_AS_ADVANCED( SH )
#IF( NOT SH )
# MESSAGE( FATAL_ERROR "unix shell not found" )
#ENDIF()



Expand Down Expand Up @@ -270,47 +293,48 @@ endif()
# replaced by standard cmake variable BUILD_TESTING
#OPTION( BUILD_LCIO_TESTS "Set to ON to build LCIO tests under src/cpp/src/TESTS" OFF )

OPTION( BUILD_LCIO_EXAMPLES "Set to ON to build LCIO examples" ON )


# lcio library
ADD_SUBDIRECTORY( ./src/cpp lcio )



# fortran examples
OPTION( BUILD_F77_TESTJOBS "Set to ON to build LCIO F77 testjobs" OFF )
IF( BUILD_F77_TESTJOBS )
ADD_SUBDIRECTORY( ./src/f77 f77 )
ENDIF()


# directory containing lcio tests
ADD_SUBDIRECTORY( ./tests )
if( BUILD_TESTING )
ADD_SUBDIRECTORY( ./tests )
endif()


### DOCUMENTATION ###########################################################

OPTION( INSTALL_DOC "Set to OFF to skip build/install Documentation" OFF )
IF( INSTALL_DOC )
ADD_SUBDIRECTORY( ./doc )
INSTALL( CODE "EXECUTE_PROCESS( COMMAND ${CMAKE_BUILD_TOOL} doc)" )
ENDIF()
if( INSTALL_DOC )
ADD_SUBDIRECTORY( ./doc )
INSTALL( CODE "EXECUTE_PROCESS( COMMAND ${CMAKE_BUILD_TOOL} doc)" )
endif()



# display some variables and write them to cache
DISPLAY_STD_VARIABLES()

MESSAGE( STATUS "BUILD_LCIO_EXAMPLES = ${BUILD_LCIO_EXAMPLES}" )
message( STATUS "BUILD_APPS = ${BUILD_APPS}" )
message( STATUS "BUILD_FORTRAN = ${BUILD_FORTRAN}" )
MESSAGE( STATUS "BUILD_F77_TESTJOBS = ${BUILD_F77_TESTJOBS}" )
MESSAGE( STATUS "BUILD_ROOTDICT = ${BUILD_ROOTDICT}" )
MESSAGE( STATUS "INSTALL_JAR = ${INSTALL_JAR}" )
MESSAGE( STATUS "LCIO_JAVA_USE_MAVEN = ${LCIO_JAVA_USE_MAVEN}" )
MESSAGE( STATUS "SIO_PRINT_DEBUG = ${SIO_PRINT_DEBUG}" )
MESSAGE( STATUS "" )
MESSAGE( "" )


# generate and install following configuration files
GENERATE_PACKAGE_CONFIGURATION_FILES( LCIOConfig.cmake LCIOConfigVersion.cmake )

INSTALL( FILES cmake/MacroCheckPackageLibs.cmake cmake/MacroCheckPackageVersion.cmake DESTINATION lib/cmake)
INSTALL( FILES cmake/MacroCheckPackageLibs.cmake cmake/MacroCheckPackageVersion.cmake DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/cmake")
Copy link
Contributor

Choose a reason for hiding this comment

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

The CMake documentation says:

DESTINATION
Specify the directory on disk to which a file will be installed. 
If a full path (with a leading slash or drive letter) is given it is 
used directly. If a relative path is given it is interpreted relative 
to the value of the CMAKE_INSTALL_PREFIX variable. The
prefix can be relocated at install time using the DESTDIR 
mechanism explained in the CMAKE_INSTALL_PREFIX variable 
documentation.

The variable CMAKE_INSTALL_PREFIX is not useful here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes i had a doubt

Loading