| /trunk/test/CMakeLists.txt |
| @@ -1,5 +1,43 @@ |
| |
| include(HepMCBuildTest) |
| |
| macro( hepmc_test testname ) |
| |
| message( STATUS "building ${testname} for ${testname}.sh" ) |
| |
| find_file( ${testname}_source ${testname}.cc ${CMAKE_CURRENT_SOURCE_DIR} |
| ${CMAKE_CURRENT_BINARY_DIR} ) |
| ADD_EXECUTABLE(${testname} ${${testname}_source} ${ARGN} ) |
| |
| if( ${CMAKE_SYSTEM_NAME} MATCHES "Windows" ) |
| message( STATUS "skipping ${testname}.sh on ${CMAKE_SYSTEM_NAME}") |
| else() |
| # automake/autoconf variables for ${testname}.sh.in |
| set(srcdir ${CMAKE_CURRENT_SOURCE_DIR} ) |
| set(builddir ${CMAKE_CURRENT_BINARY_DIR} ) |
| configure_file( ${testname}.sh.in |
| ${CMAKE_CURRENT_BINARY_DIR}/${testname}.sh @ONLY ) |
| add_test( ${testname}.sh ${CMAKE_CURRENT_BINARY_DIR}/${testname}.sh ) |
| endif() |
| |
| endmacro( hepmc_test ) |
| |
| macro( hepmc_simple_test testname ) |
| |
| message( STATUS "building simple test ${testname} " ) |
| |
| # include test in search path |
| include_directories ("${CMAKE_CURRENT_SOURCE_DIR}") |
| |
| find_file( ${testname}_source ${testname}.cc ${CMAKE_CURRENT_SOURCE_DIR} |
| ${CMAKE_CURRENT_BINARY_DIR} ) |
| #message(STATUS "building simple test ${testname} from ${${testname}_source}") |
| ADD_EXECUTABLE(${testname} ${${testname}_source} ${ARGN} ) |
| |
| add_test( ${testname} ${testname} ) |
| |
| endmacro( hepmc_simple_test ) |
| |
| |
| link_libraries( HepMC ) |
| |
| set( HepMC_tests |
| /trunk/cmake/Modules/HepMCVariables.cmake |
| @@ -51,14 +51,7 @@ |
| set( includedir "\${prefix}/include" ) |
| set( configure_input "Generated by cmake" ) |
| |
| ### autoconf variables typically do not have the path |
| ##get_filename_component( CXX ${CMAKE_CXX_COMPILER} NAME ) |
| ##if( ${CXX} MATCHES "c\\+\\+" ) |
| ## set( CXX g++ ) |
| ##endif() |
| set( CXX ${CMAKE_BASE_NAME} ) |
| ##get_filename_component( AR ${CMAKE_AR} NAME ) |
| ##get_filename_component( RANLIB ${CMAKE_RANLIB} NAME ) |
| set( CXXCPP "${CXX} -E" ) |
| if( ${CMAKE_BUILD_TYPE} MATCHES "Debug" ) |
| set( CXXFLAGS ${CMAKE_CXX_FLAGS_DEBUG} ) |
| @@ -76,26 +69,6 @@ |
| set( DIFF_Q "diff -q -b" ) |
| _hepmc_fortran_compiler() |
| |
| ### useful if you need to check a variable |
| ##message( STATUS "CMAKE_SYSTEM_NAME is ${CMAKE_SYSTEM_NAME}" ) |
| ##message( STATUS "CMAKE_BASE_NAME is ${CMAKE_BASE_NAME}" ) |
| ##message( STATUS "CMAKE_CXX_COMPILER_ID is ${CMAKE_CXX_COMPILER_ID}" ) |
| ##message( STATUS "CMAKE_COMPILER_IS_GNUCXX is ${CMAKE_COMPILER_IS_GNUCXX}" ) |
| ##message( STATUS "CMAKE_COMPILER_IS_MINGW is ${CMAKE_COMPILER_IS_MINGW}" ) |
| ##message( STATUS "CMAKE_COMPILER_IS_CYGWIN is ${CMAKE_COMPILER_IS_CYGWIN}" ) |
| ##message( STATUS "CMAKE_AR is ${CMAKE_AR}" ) |
| ##message( STATUS "CMAKE_RANLIB is ${CMAKE_RANLIB}" ) |
| ##message( STATUS "CMAKE_CXX_OUTPUT_EXTENSION is ${CMAKE_CXX_OUTPUT_EXTENSION}" ) |
| ##message( STATUS "CMAKE_SHARED_LIBRARY_CXX_FLAGS is ${CMAKE_SHARED_LIBRARY_CXX_FLAGS}" ) |
| ##message( STATUS "CMAKE_SHARED_MODULE_CXX_FLAGS is ${CMAKE_SHARED_MODULE_CXX_FLAGS}" ) |
| ##message( STATUS "CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS is ${CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS}" ) |
| ##message( STATUS "CMAKE_CXX_FLAGS is ${CMAKE_CXX_FLAGS}" ) |
| ##message( STATUS "CMAKE_CXX_FLAGS_DEBUG is ${CMAKE_CXX_FLAGS_DEBUG}" ) |
| ##message( STATUS "CMAKE_CXX_FLAGS_RELEASE is ${CMAKE_CXX_FLAGS_RELEASE}" ) |
| ##message( STATUS "CMAKE_CXX_FLAGS_RELWITHDEBINFO is ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}" ) |
| ##message( STATUS "CMAKE_CXX_STANDARD_LIBRARIES is ${CMAKE_CXX_STANDARD_LIBRARIES}" ) |
| ##message( STATUS "CMAKE_CXX_LINK_FLAGS is ${CMAKE_CXX_LINK_FLAGS}" ) |
| |
| endmacro( hepmc_autoconf_variables ) |
| |
| macro( hepmc_set_compiler_flags ) |
| @@ -111,16 +84,11 @@ |
| set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O -ansi -pedantic -Wall -D_GNU_SOURCE") |
| endif(CMAKE_COMPILER_IS_GNUCXX) |
| if( ${CMAKE_SYSTEM_NAME} MATCHES "Windows" ) |
| ##message( STATUS "system is Windows" ) |
| ##message( STATUS "CMAKE_BASE_NAME is ${CMAKE_BASE_NAME}" ) |
| if( ${CMAKE_BASE_NAME} MATCHES "cl" ) |
| ##message( STATUS "compiler is MSVC" ) |
| ##message( STATUS "incoming basic compiler flags are ${CMAKE_CXX_FLAGS}") |
| set(CMAKE_C_FLAGS "/EHsc /nologo /GR /MD") |
| set(CMAKE_CXX_FLAGS "/EHsc /nologo /GR /MD") |
| endif() |
| endif() |
| hepmc_autoconf_variables() |
| #message(STATUS "F77: ${F77}") |
| message( STATUS "compiling with ${CMAKE_BASE_NAME} ${CMAKE_CXX_FLAGS} ${CXXFLAGS}") |
| endmacro( hepmc_set_compiler_flags ) |
| /trunk/cmake/Modules/HepMCUseCpack.cmake |
| @@ -1,7 +1,78 @@ |
| # define the environment for cpack |
| # |
| include(HepMCFindCompiler) |
| |
| |
| # |
| # Runs compiler with "-dumpversion" and parses major/minor |
| # version with a regex. |
| # |
| FUNCTION(_My_COMPILER_DUMPVERSION _OUTPUT_VERSION) |
| |
| EXEC_PROGRAM(${CMAKE_CXX_COMPILER} |
| ARGS ${CMAKE_CXX_COMPILER_ARG1} -dumpversion |
| OUTPUT_VARIABLE _my_COMPILER_VERSION |
| ) |
| set( COMPILER_VERSION ${_my_COMPILER_VERSION} PARENT_SCOPE) |
| STRING(REGEX REPLACE "([0-9])\\.([0-9])(\\.[0-9])?" "\\1\\2" |
| _my_COMPILER_VERSION ${_my_COMPILER_VERSION}) |
| |
| SET(${_OUTPUT_VERSION} ${_my_COMPILER_VERSION} PARENT_SCOPE) |
| ENDFUNCTION() |
| |
| # |
| # End functions/macros |
| # |
| #------------------------------------------------------------------------------- |
| |
| |
| macro( hepmc_find_compiler ) |
| if (My_COMPILER) |
| SET (CPack_COMPILER_STRING ${My_COMPILER}) |
| message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " |
| "using user-specified My_COMPILER = ${CPack_COMPILER_STRING}") |
| else(My_COMPILER) |
| # Attempt to guess the compiler suffix |
| # NOTE: this is not perfect yet, if you experience any issues |
| # please report them and use the My_COMPILER variable |
| # to work around the problems. |
| if (MSVC90) |
| SET (CPack_COMPILER_STRING "-vc90") |
| elseif (MSVC80) |
| SET (CPack_COMPILER_STRING "-vc80") |
| elseif (MSVC71) |
| SET (CPack_COMPILER_STRING "-vc71") |
| elseif (MSVC70) # Good luck! |
| SET (CPack_COMPILER_STRING "-vc7") # yes, this is correct |
| elseif (MSVC60) # Good luck! |
| SET (CPack_COMPILER_STRING "-vc6") # yes, this is correct |
| elseif (BORLAND) |
| SET (CPack_COMPILER_STRING "-bcb") |
| elseif("${CMAKE_CXX_COMPILER}" MATCHES "icl" |
| OR "${CMAKE_CXX_COMPILER}" MATCHES "icpc") |
| if(WIN32) |
| set (CPack_COMPILER_STRING "-iw") |
| else() |
| set (CPack_COMPILER_STRING "-il") |
| endif() |
| elseif (MINGW) |
| _My_COMPILER_DUMPVERSION(CPack_COMPILER_STRING_VERSION) |
| SET (CPack_COMPILER_STRING "-mgw${CPack_COMPILER_STRING_VERSION}") |
| elseif (UNIX) |
| if (CMAKE_COMPILER_IS_GNUCXX) |
| _My_COMPILER_DUMPVERSION(CPack_COMPILER_STRING_VERSION) |
| # Determine which version of GCC we have. |
| if(APPLE) |
| SET (CPack_COMPILER_STRING "-xgcc${CPack_COMPILER_STRING_VERSION}") |
| else() |
| SET (CPack_COMPILER_STRING "-gcc${CPack_COMPILER_STRING_VERSION}") |
| endif() |
| endif (CMAKE_COMPILER_IS_GNUCXX) |
| endif() |
| message(STATUS "Using compiler ${CPack_COMPILER_STRING}") |
| endif(My_COMPILER) |
| endmacro( hepmc_find_compiler ) |
| |
| |
| # note that hepmc_parse_version is used to define VERSION_MAJOR, etc. |
| set( CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR} ) |
| set( CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR} ) |
| @@ -12,15 +83,20 @@ |
| |
| hepmc_find_compiler() |
| |
| if ( ${SLTYPE} MATCHES "noarch" ) |
| set( PACKAGE_BASENAME ${SLTYPE} ) |
| else () |
| if(${CMAKE_SYSTEM_NAME} MATCHES "Linux" ) |
| set(SLTYPE "slc") |
| elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin" ) |
| set(SLTYPE "mac106") |
| elseif(${CMAKE_SYSTEM_NAME} MATCHES "Windows" ) |
| set(SLTYPE "winxp") |
| endif () |
| message(STATUS "CMAKE_HOST_SYSTEM_VERSION: ${CMAKE_HOST_SYSTEM_VERSION}") |
| message(STATUS "CMAKE_SYSTEM_VERSION: ${CMAKE_SYSTEM_VERSION}") |
| if ( NOT CPack_COMPILER_STRING ) |
| set( PACKAGE_BASENAME ${SLTYPE}-${CMAKE_SYSTEM_PROCESSOR} ) |
| set( PACKAGE_BASENAME ${CMAKE_SYSTEM_PROCESSOR}-${SLTYPE} ) |
| else () |
| set( PACKAGE_BASENAME ${SLTYPE}-${CMAKE_SYSTEM_PROCESSOR}${CPack_COMPILER_STRING} ) |
| set( PACKAGE_BASENAME ${CMAKE_SYSTEM_PROCESSOR}-${SLTYPE}${CPack_COMPILER_STRING} ) |
| endif () |
| endif () |
| if ( NOT qualifier ) |
| set( CPACK_SYSTEM_NAME ${PACKAGE_BASENAME} ) |
| else () |
| /trunk/CMakeLists.txt |
| @@ -32,14 +32,25 @@ |
| message(FATAL_ERROR "You must specify the length units with -Dlength:STRING=[MM|CM]") |
| endif() |
| |
| message(STATUS "default momentum and length are ${HEPMC_DEFAULT_MOM_UNIT} ${HEPMC_DEFAULT_LEN_UNIT}") |
| |
| # find the HepMC cmake modules |
| #set(CMAKE_MODULE_PATH "${CMAKE_ROOT}/Modules") |
| set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules ${CMAKE_MODULE_PATH}) |
| message(STATUS "module path is ${CMAKE_MODULE_PATH}" ) |
| |
| # make sure we are not building from within the source code directory |
| include(HepMCOutOfSourceBuild) |
| hepmc_ensure_out_of_source_build() |
| string(COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" in_source) |
| string( REGEX MATCH "${CMAKE_SOURCE_DIR}/" in_source_subdir |
| "${CMAKE_BINARY_DIR}") |
| if (in_source OR in_source_subdir) |
| message(FATAL_ERROR " |
| ERROR: In source builds of this project are not allowed. |
| A separate build directory is required. |
| Please create one and run cmake from the build directory. |
| Also note that cmake has just added files to your source code directory. |
| We suggest getting a new copy of the source code. |
| Otherwise, delete `CMakeCache.txt' and the directory `CMakeFiles'. |
| ") |
| endif () |
| |
| # build_docs is OFF (false) by default |
| if ( build_docs ) |
| @@ -50,10 +61,8 @@ |
| |
| # various handy macros |
| include(HepMCVariables) |
| include(HepMCParseVersion) |
| #include(HepMCParseVersion) |
| |
| include(CMakeDetermineFortranCompiler) |
| |
| # because we want to move these libraries about, |
| # do not embed full path in shared libraries or executables |
| set (CMAKE_SKIP_RPATH) |
| @@ -66,8 +75,14 @@ |
| #build all libraries in a single directory to facilitate testing |
| SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) |
| |
| # parse the version |
| STRING( REGEX REPLACE "^([0-9]+)[.][0-9]+[.][0-9]+.*" "\\1" VERSION_MAJOR "${version}" ) |
| STRING( REGEX REPLACE "^[0-9]+[.]([0-9]+)[.][0-9]+.*" "\\1" VERSION_MINOR "${version}" ) |
| STRING( REGEX REPLACE "^[0-9]+[.][0-9]+[.]([0-9]+)+.*" "\\1" VERSION_PATCH "${version}" ) |
| message(STATUS "${project} version ${version} parses to ${VERSION_MAJOR} ${VERSION_MINOR} ${VERSION_PATCH}" ) |
| |
| # set our preferred compiler flags and other variables |
| hepmc_parse_version() |
| include(CMakeDetermineFortranCompiler) |
| hepmc_set_compiler_flags() |
| |
| add_subdirectory(HepMC) |