diff --git a/cmake/CheckCFileRuns.cmake b/cmake/CheckCFileRuns.cmake index 4523aa88..4a02fb6a 100644 --- a/cmake/CheckCFileRuns.cmake +++ b/cmake/CheckCFileRuns.cmake @@ -24,25 +24,25 @@ # (To distributed this file outside of CMake, substitute the full # License text for the above reference.) -MACRO(CHECK_C_FILE_RUNS SOURCE VAR) - IF("${VAR}" MATCHES "^${VAR}$") - SET(MACRO_CHECK_FUNCTION_DEFINITIONS +macro(CHECK_C_FILE_RUNS SOURCE VAR) + if("${VAR}" MATCHES "^${VAR}$") + set(MACRO_CHECK_FUNCTION_DEFINITIONS "-D${VAR} ${CMAKE_REQUIRED_FLAGS}") - IF(CMAKE_REQUIRED_LIBRARIES) - SET(CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES + if(CMAKE_REQUIRED_LIBRARIES) + set(CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}") - ELSE(CMAKE_REQUIRED_LIBRARIES) - SET(CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES) - ENDIF(CMAKE_REQUIRED_LIBRARIES) - IF(CMAKE_REQUIRED_INCLUDES) - SET(CHECK_C_SOURCE_COMPILES_ADD_INCLUDES + else(CMAKE_REQUIRED_LIBRARIES) + set(CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES) + endif(CMAKE_REQUIRED_LIBRARIES) + if(CMAKE_REQUIRED_INCLUDES) + set(CHECK_C_SOURCE_COMPILES_ADD_INCLUDES "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}") - ELSE(CMAKE_REQUIRED_INCLUDES) - SET(CHECK_C_SOURCE_COMPILES_ADD_INCLUDES) - ENDIF(CMAKE_REQUIRED_INCLUDES) + else(CMAKE_REQUIRED_INCLUDES) + set(CHECK_C_SOURCE_COMPILES_ADD_INCLUDES) + endif(CMAKE_REQUIRED_INCLUDES) - MESSAGE(STATUS "Performing Test ${VAR}") - TRY_RUN(${VAR}_EXITCODE ${VAR}_COMPILED + message(STATUS "Performing Test ${VAR}") + try_run(${VAR}_EXITCODE ${VAR}_COMPILED ${CMAKE_BINARY_DIR} ${SOURCE} COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} ${FILE_RUN_DEFINITIONS} @@ -52,35 +52,35 @@ MACRO(CHECK_C_FILE_RUNS SOURCE VAR) "${CHECK_C_SOURCE_COMPILES_ADD_INCLUDES}" COMPILE_OUTPUT_VARIABLE OUTPUT) # if it did not compile make the return value fail code of 1 - IF(NOT ${VAR}_COMPILED) - SET(${VAR}_EXITCODE 1) - ENDIF(NOT ${VAR}_COMPILED) + if(NOT ${VAR}_COMPILED) + set(${VAR}_EXITCODE 1) + endif(NOT ${VAR}_COMPILED) # if the return value was 0 then it worked - IF("${${VAR}_EXITCODE}" EQUAL 0) - SET(${VAR} 1 CACHE INTERNAL "Test ${VAR}") - MESSAGE(STATUS "Performing Test ${VAR} - Success") - FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + if("${${VAR}_EXITCODE}" EQUAL 0) + set(${VAR} 1 CACHE INTERNAL "Test ${VAR}") + message(STATUS "Performing Test ${VAR} - Success") + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Performing C SOURCE FILE Test ${VAR} succeded with the following output:\n" "${OUTPUT}\n" "Return value: ${${VAR}}\n" "Source file was:\n${SOURCE}\n") - ELSE("${${VAR}_EXITCODE}" EQUAL 0) - IF(CMAKE_CROSSCOMPILING AND "${${VAR}_EXITCODE}" MATCHES "FAILED_TO_RUN") - SET(${VAR} "${${VAR}_EXITCODE}") - ELSE(CMAKE_CROSSCOMPILING AND "${${VAR}_EXITCODE}" MATCHES "FAILED_TO_RUN") - SET(${VAR} "" CACHE INTERNAL "Test ${VAR}") - ENDIF(CMAKE_CROSSCOMPILING AND "${${VAR}_EXITCODE}" MATCHES "FAILED_TO_RUN") + else("${${VAR}_EXITCODE}" EQUAL 0) + if(CMAKE_CROSSCOMPILING AND "${${VAR}_EXITCODE}" MATCHES "FAILED_TO_RUN") + set(${VAR} "${${VAR}_EXITCODE}") + else(CMAKE_CROSSCOMPILING AND "${${VAR}_EXITCODE}" MATCHES "FAILED_TO_RUN") + set(${VAR} "" CACHE INTERNAL "Test ${VAR}") + endif(CMAKE_CROSSCOMPILING AND "${${VAR}_EXITCODE}" MATCHES "FAILED_TO_RUN") - MESSAGE(STATUS "Performing Test ${VAR} - Failed") - FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + message(STATUS "Performing Test ${VAR} - Failed") + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Performing C SOURCE FILE Test ${VAR} failed with the following output:\n" "${OUTPUT}\n" "Return value: ${${VAR}_EXITCODE}\n" "Source file was:\n${SOURCE}\n") - ENDIF("${${VAR}_EXITCODE}" EQUAL 0) - ENDIF("${VAR}" MATCHES "^${VAR}$") -ENDMACRO(CHECK_C_FILE_RUNS) + endif("${${VAR}_EXITCODE}" EQUAL 0) + endif("${VAR}" MATCHES "^${VAR}$") +endmacro(CHECK_C_FILE_RUNS) # Local Variables: # tab-width: 8 diff --git a/cmake/FindLEMON.cmake b/cmake/FindLEMON.cmake index d72f4576..c24e4d4d 100644 --- a/cmake/FindLEMON.cmake +++ b/cmake/FindLEMON.cmake @@ -15,18 +15,18 @@ # Copyright 2009 Kitware, Inc. # Copyright 2006 Tristan Carel # All rights reserved. -# +# # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: -# +# # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. -# +# # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# +# # * The names of the authors may not be used to endorse or promote # products derived from this software without specific prior written # permission. diff --git a/cmake/FindPERPLEX.cmake b/cmake/FindPERPLEX.cmake index 13b0cdfe..5c39cc56 100644 --- a/cmake/FindPERPLEX.cmake +++ b/cmake/FindPERPLEX.cmake @@ -15,18 +15,18 @@ # Copyright 2009 Kitware, Inc. # Copyright 2006 Tristan Carel # All rights reserved. -# +# # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: -# +# # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. -# +# # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# +# # * The names of the authors may not be used to endorse or promote # products derived from this software without specific prior written # permission. diff --git a/cmake/LEMON_Util.cmake b/cmake/LEMON_Util.cmake index 42a730b9..fe9c2d86 100644 --- a/cmake/LEMON_Util.cmake +++ b/cmake/LEMON_Util.cmake @@ -24,18 +24,18 @@ # Copyright 2009 Kitware, Inc. # Copyright 2006 Tristan Carel # All rights reserved. -# +# # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: -# +# # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. -# +# # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# +# # * The names of the authors may not be used to endorse or promote # products derived from this software without specific prior written # permission. @@ -106,9 +106,9 @@ macro(LEMON_TARGET Name LemonInput LemonSource LemonHeader) # rename generated outputs if(NOT "${LemonSource}" STREQUAL "${LEMON_GEN_SOURCE}") add_custom_command( - OUTPUT ${LemonSource} + OUTPUT ${LemonSource} COMMAND ${CMAKE_COMMAND} -E copy ${LEMON_GEN_SOURCE} ${LemonSource} - DEPENDS ${LemonInput} ${LEMON_EXECUTABLE_TARGET} ${LEMON_GEN_SOURCE} + DEPENDS ${LemonInput} ${LEMON_EXECUTABLE_TARGET} ${LEMON_GEN_SOURCE} ) set(LEMON_${Name}_OUTPUTS ${LemonSource} ${LEMON_${Name}_OUTPUTS}) endif(NOT "${LemonSource}" STREQUAL "${LEMON_GEN_SOURCE}") @@ -116,7 +116,7 @@ macro(LEMON_TARGET Name LemonInput LemonSource LemonHeader) add_custom_command( OUTPUT ${LemonHeader} COMMAND ${CMAKE_COMMAND} -E copy ${LEMON_GEN_HEADER} ${LemonHeader} - DEPENDS ${LemonInput} ${LEMON_EXECUTABLE_TARGET} ${LEMON_GEN_HEADER} + DEPENDS ${LemonInput} ${LEMON_EXECUTABLE_TARGET} ${LEMON_GEN_HEADER} ) set(LEMON_${Name}_OUTPUTS ${LemonHeader} ${LEMON_${Name}_OUTPUTS}) endif(NOT "${LemonHeader}" STREQUAL "${LEMON_GEN_HEADER}") @@ -125,7 +125,7 @@ macro(LEMON_TARGET Name LemonInput LemonSource LemonHeader) # make sure we clean up generated output and copied input if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") - set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "${LEMON_${Name}_OUTPUTS}") + set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "${LEMON_${Name}_OUTPUTS}") else("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "${LEMON_${Name}_OUTPUTS};${LEMON_BIN_INPUT}") endif("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") diff --git a/cmake/PERPLEX_Util.cmake b/cmake/PERPLEX_Util.cmake index 3aded4d9..be12c1f2 100644 --- a/cmake/PERPLEX_Util.cmake +++ b/cmake/PERPLEX_Util.cmake @@ -1,5 +1,5 @@ # Defines two macros - PERPLEX_TARGET, which takes perplex inputs and -# runs both perplex and re2c to generate C source code/headers, and +# runs both perplex and re2c to generate C source code/headers, and # ADD_PERPLEX_LEMON_DEPENDENCY which is used to set up dependencies between # scanner and parser targets when necessary. # @@ -21,7 +21,7 @@ # ${PERPLEX_MyScanner_OUTPUTS} # ) # ==================================================================== -# +# #============================================================================= # # Originally based off of FindBISON.cmake from Kitware's CMake distribution @@ -31,18 +31,18 @@ # Copyright 2009 Kitware, Inc. # Copyright 2006 Tristan Carel # All rights reserved. -# +# # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: -# +# # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. -# +# # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. -# +# # * The names of the authors may not be used to endorse or promote # products derived from this software without specific prior written # permission. diff --git a/cmake/SC_Build_opts.cmake b/cmake/SC_Build_opts.cmake index b7a63a71..44c74458 100644 --- a/cmake/SC_Build_opts.cmake +++ b/cmake/SC_Build_opts.cmake @@ -1,37 +1,37 @@ # testing and compilation options, build output dirs, install dirs, etc # included by root CMakeLists -IF( NOT DEFINED INCLUDE_INSTALL_DIR ) - SET( INCLUDE_INSTALL_DIR include ) -ENDIF( NOT DEFINED INCLUDE_INSTALL_DIR ) +if(NOT DEFINED INCLUDE_INSTALL_DIR) + set(INCLUDE_INSTALL_DIR include) +endif(NOT DEFINED INCLUDE_INSTALL_DIR) -IF( NOT DEFINED LIB_INSTALL_DIR ) - SET( LIB_INSTALL_DIR lib ) -ENDIF( NOT DEFINED LIB_INSTALL_DIR ) +if(NOT DEFINED LIB_INSTALL_DIR) + set(LIB_INSTALL_DIR lib) +endif(NOT DEFINED LIB_INSTALL_DIR) -IF( NOT DEFINED BIN_INSTALL_DIR ) - SET( BIN_INSTALL_DIR bin ) -ENDIF( NOT DEFINED BIN_INSTALL_DIR ) +if(NOT DEFINED BIN_INSTALL_DIR) + set(BIN_INSTALL_DIR bin) +endif(NOT DEFINED BIN_INSTALL_DIR) -IF( NOT DEFINED SC_BUILD_TYPE ) - SET( SC_BUILD_TYPE "Debug" CACHE STRING "Build type" ) # By default set debug build -ENDIF( NOT DEFINED SC_BUILD_TYPE ) -IF(NOT SC_IS_SUBBUILD) - SET(CMAKE_BUILD_TYPE ${SC_BUILD_TYPE} CACHE INTERNAL "Build type, immutable" FORCE ) -ELSE(NOT SC_IS_SUBBUILD) - SET(CMAKE_BUILD_TYPE ${SC_BUILD_TYPE} ) -ENDIF(NOT SC_IS_SUBBUILD) +if(NOT DEFINED SC_BUILD_TYPE) + set(SC_BUILD_TYPE "Debug" CACHE STRING "Build type") # By default set debug build +endif(NOT DEFINED SC_BUILD_TYPE) +if(NOT SC_IS_SUBBUILD) + set(CMAKE_BUILD_TYPE ${SC_BUILD_TYPE} CACHE INTERNAL "Build type, immutable" FORCE) +else(NOT SC_IS_SUBBUILD) + set(CMAKE_BUILD_TYPE ${SC_BUILD_TYPE}) +endif(NOT SC_IS_SUBBUILD) # Define helper macro OPTION_WITH_DEFAULT -MACRO( OPTION_WITH_DEFAULT OPTION_NAME OPTION_STRING OPTION_DEFAULT ) - IF( NOT DEFINED ${OPTION_NAME} ) - SET( ${OPTION_NAME} ${OPTION_DEFAULT} ) - ENDIF( NOT DEFINED ${OPTION_NAME} ) - OPTION( ${OPTION_NAME} "${OPTION_STRING}" ${${OPTION_NAME}} ) -ENDMACRO( OPTION_WITH_DEFAULT OPTION_NAME OPTION_STRING OPTION_DEFAULT ) +macro(OPTION_WITH_DEFAULT OPTION_NAME OPTION_STRING OPTION_DEFAULT) + if(NOT DEFINED ${OPTION_NAME}) + set(${OPTION_NAME} ${OPTION_DEFAULT}) + endif(NOT DEFINED ${OPTION_NAME}) + option(${OPTION_NAME} "${OPTION_STRING}" ${${OPTION_NAME}}) +endmacro(OPTION_WITH_DEFAULT OPTION_NAME OPTION_STRING OPTION_DEFAULT) # build shared libs by default -OPTION_WITH_DEFAULT(SC_BUILD_SHARED_LIBS "Build shared libs" ON ) +OPTION_WITH_DEFAULT(SC_BUILD_SHARED_LIBS "Build shared libs" ON) # don't build static libs by default OPTION_WITH_DEFAULT(SC_BUILD_STATIC_LIBS "Build static libs" OFF) @@ -42,34 +42,34 @@ OPTION_WITH_DEFAULT(SC_CPP_GENERATOR "Compile exp2cxx" ON) OPTION_WITH_DEFAULT(SC_MEMMGR_ENABLE_CHECKS "Enable sc_memmgr's memory leak detection" OFF) OPTION_WITH_DEFAULT(SC_TRACE_FPRINTF "Enable extra comments in generated code so the code's source in exp2cxx may be located" OFF) -OPTION(SC_BUILD_EXPRESS_ONLY "Only build express parser." OFF) -MARK_AS_ADVANCED(SC_BUILD_EXPRESS_ONLY) +option(SC_BUILD_EXPRESS_ONLY "Only build express parser." OFF) +mark_as_advanced(SC_BUILD_EXPRESS_ONLY) #--------------------------------------------------------------------- # Coverage option -OPTION_WITH_DEFAULT( SC_ENABLE_COVERAGE "Enable code coverage test" OFF ) -IF(SC_ENABLE_COVERAGE) - SET(SC_ENABLE_TESTING ON CACHE BOOL "Testing enabled by coverage option" FORCE) +OPTION_WITH_DEFAULT(SC_ENABLE_COVERAGE "Enable code coverage test" OFF) +if(SC_ENABLE_COVERAGE) + set(SC_ENABLE_TESTING ON CACHE BOOL "Testing enabled by coverage option" FORCE) # build static libs, better coverage report - SET(SC_BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared libs" FORCE ) - SET(SC_BUILD_STATIC_LIBS ON CACHE BOOL "Build static libs" FORCE ) - SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -fprofile-arcs -ftest-coverage" CACHE STRING "Extra compile flags required by code coverage" FORCE) - SET(CMAKE_C_FLAGS_DEBUG "-O0 -g -fprofile-arcs -ftest-coverage" CACHE STRING "Extra compile flags required by code coverage" FORCE) - SET(CMAKE_MODULE_LINKER_FLAGS_DEBUG "-fprofile-arcs -ftest-coverage" CACHE STRING "Extra linker flags required by code coverage" FORCE) - SET(SC_BUILD_TYPE "Debug" CACHE STRING "Build type required by testing framework" FORCE) - SET( SC_PYTHON_GENERATOR OFF ) #won't build with static libs -ENDIF(SC_ENABLE_COVERAGE) + set(SC_BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared libs" FORCE) + set(SC_BUILD_STATIC_LIBS ON CACHE BOOL "Build static libs" FORCE) + set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -fprofile-arcs -ftest-coverage" CACHE STRING "Extra compile flags required by code coverage" FORCE) + set(CMAKE_C_FLAGS_DEBUG "-O0 -g -fprofile-arcs -ftest-coverage" CACHE STRING "Extra compile flags required by code coverage" FORCE) + set(CMAKE_MODULE_LINKER_FLAGS_DEBUG "-fprofile-arcs -ftest-coverage" CACHE STRING "Extra linker flags required by code coverage" FORCE) + set(SC_BUILD_TYPE "Debug" CACHE STRING "Build type required by testing framework" FORCE) + set(SC_PYTHON_GENERATOR OFF) #won't build with static libs +endif(SC_ENABLE_COVERAGE) #--------------------------------------------------------------------- # Testing option -OPTION_WITH_DEFAULT( SC_ENABLE_TESTING "Enable unittesting framework" OFF ) -IF(SC_ENABLE_TESTING) - if( NOT DEFINED SC_BUILD_SCHEMAS ) - set( SC_BUILD_SCHEMAS "ALL" ) #test all schemas, unless otherwise specified +OPTION_WITH_DEFAULT(SC_ENABLE_TESTING "Enable unittesting framework" OFF) +if(SC_ENABLE_TESTING) + if(NOT DEFINED SC_BUILD_SCHEMAS) + set(SC_BUILD_SCHEMAS "ALL") #test all schemas, unless otherwise specified endif() - INCLUDE(CTest) + include(CTest) ENABLE_TESTING() -ENDIF(SC_ENABLE_TESTING) +endif(SC_ENABLE_TESTING) #--------------------------------------------------------------------- # The following logic is what allows binaries to run successfully in @@ -99,37 +99,37 @@ set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) # When this is a subbuild, assume that the parent project controls all of the following #====================================================================================== -IF( NOT SC_IS_SUBBUILD ) +if(NOT SC_IS_SUBBUILD) # Output directories. In a separate file so it can be used by the schema scanner CMake as well. - include( ${SC_CMAKE_DIR}/SC_Outdirs.cmake ) + include(${SC_CMAKE_DIR}/SC_Outdirs.cmake) #----------------------------------------------------------------------------- # Configure install locations. Only do this if CMAKE_INSTALL_PREFIX hasn't # been set already, to try and allow parent builds (if any) some control. # # Need a good Debug location for Windows. - IF(NOT WIN32) - IF (${CMAKE_BUILD_TYPE} MATCHES "Debug") - SET(SC_INSTALL_PREFIX "${SC_SOURCE_DIR}/../sc-install") - ELSE() - SET(SC_INSTALL_PREFIX "/usr/local") - ENDIF() - ENDIF(NOT WIN32) - SET( SC_INSTALL_PREFIX ${SC_INSTALL_PREFIX} CACHE - PATH "Install prefix prepended to target to create install location" ) - SET( CMAKE_INSTALL_PREFIX ${SC_INSTALL_PREFIX} CACHE INTERNAL "Prefix prepended to install directories if target destination is not absolute, immutable" FORCE ) + if(NOT WIN32) + if(${CMAKE_BUILD_TYPE} MATCHES "Debug") + set(SC_INSTALL_PREFIX "${SC_SOURCE_DIR}/../sc-install") + else() + set(SC_INSTALL_PREFIX "/usr/local") + endif() + endif(NOT WIN32) + set(SC_INSTALL_PREFIX ${SC_INSTALL_PREFIX} CACHE + PATH "Install prefix prepended to target to create install location") + set(CMAKE_INSTALL_PREFIX ${SC_INSTALL_PREFIX} CACHE INTERNAL "Prefix prepended to install directories if target destination is not absolute, immutable" FORCE) #----------------------------------------------------------------------------- # SC Packaging # $make package - SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "STEPcode") - SET(CPACK_SET_DESTDIR "ON") - SET(CPACK_PACKAGE_VERSION_MAJOR ${SC_VERSION_MAJOR}) - SET(CPACK_PACKAGE_VERSION_MINOR ${SC_VERSION_MINOR}) - SET(CPACK_PACKAGE_NAME SC ) - SET(CPACK_PACKAGE_CONTACT "SC Developers ") - INCLUDE(CPack) + set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "STEPcode") + set(CPACK_SET_DESTDIR "ON") + set(CPACK_PACKAGE_VERSION_MAJOR ${SC_VERSION_MAJOR}) + set(CPACK_PACKAGE_VERSION_MINOR ${SC_VERSION_MINOR}) + set(CPACK_PACKAGE_NAME SC) + set(CPACK_PACKAGE_CONTACT "SC Developers ") + include(CPack) #----------------------------------------------------------------------------- # Uninstall target diff --git a/cmake/SC_CXX_schema_macros.cmake b/cmake/SC_CXX_schema_macros.cmake index 58f0b7b7..0de210ec 100644 --- a/cmake/SC_CXX_schema_macros.cmake +++ b/cmake/SC_CXX_schema_macros.cmake @@ -1,73 +1,73 @@ # macros to be used in the CMakeLists generated by the schema scanner # uses SC_GENERATE_CXX_ONESHOT - if true, files will only be generated once. this is useful when debugging and modifying code, not otherwise. TODO: print a warning when set -if( NOT DEFINED SC_GENERATE_CXX_ONESHOT ) - set( SC_GENERATE_CXX_ONESHOT FALSE ) -endif( NOT DEFINED SC_GENERATE_CXX_ONESHOT ) +if(NOT DEFINED SC_GENERATE_CXX_ONESHOT) + set(SC_GENERATE_CXX_ONESHOT FALSE) +endif(NOT DEFINED SC_GENERATE_CXX_ONESHOT) # find all part 21 files in schema dir, add a test for each one -MACRO( P21_TESTS sfile ) - get_filename_component( SCHEMA_DIR ${sfile} PATH ) - file( GLOB_RECURSE P21_FILES ${SCHEMA_DIR}/*.stp ${SCHEMA_DIR}/*.step ${SCHEMA_DIR}/*.p21 ${SCHEMA_DIR}/*.ifc ) - foreach( TEST_FILE ${P21_FILES} ) - get_filename_component( FNAME ${TEST_FILE} NAME_WE ) - add_test( NAME read_write_cpp_${PROJECT_NAME}_${FNAME} +macro(P21_TESTS sfile) + get_filename_component(SCHEMA_DIR ${sfile} PATH) + file(GLOB_RECURSE P21_FILES ${SCHEMA_DIR}/*.stp ${SCHEMA_DIR}/*.step ${SCHEMA_DIR}/*.p21 ${SCHEMA_DIR}/*.ifc) + foreach(TEST_FILE ${P21_FILES}) + get_filename_component(FNAME ${TEST_FILE} NAME_WE) + add_test(NAME read_write_cpp_${PROJECT_NAME}_${FNAME} WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - COMMAND p21read_${PROJECT_NAME} ${TEST_FILE} ) - set_tests_properties( read_write_cpp_${PROJECT_NAME}_${FNAME} PROPERTIES DEPENDS build_cpp_${PROJECT_NAME} LABELS cpp_schema_rw ) + COMMAND p21read_${PROJECT_NAME} ${TEST_FILE}) + set_tests_properties(read_write_cpp_${PROJECT_NAME}_${FNAME} PROPERTIES DEPENDS build_cpp_${PROJECT_NAME} LABELS cpp_schema_rw) if(NOT WIN32) - add_test( NAME read_lazy_cpp_${PROJECT_NAME}_${FNAME} - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - COMMAND lazy_${PROJECT_NAME} ${TEST_FILE} ) - set_tests_properties( read_lazy_cpp_${PROJECT_NAME}_${FNAME} PROPERTIES DEPENDS build_lazy_cpp_${PROJECT_NAME} LABELS cpp_schema_rw ) + add_test(NAME read_lazy_cpp_${PROJECT_NAME}_${FNAME} + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + COMMAND lazy_${PROJECT_NAME} ${TEST_FILE}) + set_tests_properties(read_lazy_cpp_${PROJECT_NAME}_${FNAME} PROPERTIES DEPENDS build_lazy_cpp_${PROJECT_NAME} LABELS cpp_schema_rw) endif(NOT WIN32) endforeach() -ENDMACRO( P21_TESTS sfile ) +endmacro(P21_TESTS sfile) # -MACRO( SCHEMA_EXES ) +macro(SCHEMA_EXES) RELATIVE_PATH_TO_TOPLEVEL(${CMAKE_CURRENT_SOURCE_DIR} RELATIVE_PATH_COMPONENT) - SC_ADDEXEC( p21read_${PROJECT_NAME} "${RELATIVE_PATH_COMPONENT}/src/test/p21read/p21read.cc" "${PROJECT_NAME};stepdai;stepcore;stepeditor;steputils;base" "TESTABLE" ) - #add_dependencies( p21read_${PROJECT_NAME} version_string ) + SC_ADDEXEC(p21read_${PROJECT_NAME} "${RELATIVE_PATH_COMPONENT}/src/test/p21read/p21read.cc" "${PROJECT_NAME};stepdai;stepcore;stepeditor;steputils;base" "TESTABLE") + #add_dependencies(p21read_${PROJECT_NAME} version_string) if(NOT WIN32) - SC_ADDEXEC( lazy_${PROJECT_NAME} "${RELATIVE_PATH_COMPONENT}/src/cllazyfile/lazy_test.cc" "${PROJECT_NAME};steplazyfile;stepdai;stepcore;stepeditor;steputils;base" "TESTABLE" ) - #add_dependencies( lazy_${PROJECT_NAME} version_string ) + SC_ADDEXEC(lazy_${PROJECT_NAME} "${RELATIVE_PATH_COMPONENT}/src/cllazyfile/lazy_test.cc" "${PROJECT_NAME};steplazyfile;stepdai;stepcore;stepeditor;steputils;base" "TESTABLE") + #add_dependencies(lazy_${PROJECT_NAME} version_string) endif(NOT WIN32) #add user-defined executables - foreach( src ${SC_SDAI_ADDITIONAL_EXES_SRCS} ) - get_filename_component( name ${src} NAME_WE ) - get_filename_component( path ${src} ABSOLUTE ) - SC_ADDEXEC( ${name}_${PROJECT_NAME} "${src}" "${PROJECT_NAME};stepdai;stepcore;stepeditor;steputils;base" "TESTABLE" ) - add_dependencies( ${name}_${PROJECT_NAME} version_string ) - #set_target_properties( ${name}_${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "${${PROJECT_NAME}_COMPILE_FLAGS} -I${path}" ) - endforeach( src ${SC_SDAI_ADDITIONAL_EXES_SRCS} ) -ENDMACRO( SCHEMA_EXES ) + foreach(src ${SC_SDAI_ADDITIONAL_EXES_SRCS}) + get_filename_component(name ${src} NAME_WE) + get_filename_component(path ${src} ABSOLUTE) + SC_ADDEXEC(${name}_${PROJECT_NAME} "${src}" "${PROJECT_NAME};stepdai;stepcore;stepeditor;steputils;base" "TESTABLE") + add_dependencies(${name}_${PROJECT_NAME} version_string) + #set_target_properties(${name}_${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "${${PROJECT_NAME}_COMPILE_FLAGS} -I${path}") + endforeach(src ${SC_SDAI_ADDITIONAL_EXES_SRCS}) +ENDMACRO(SCHEMA_EXES) # label the tests and set dependencies -MACRO( SCHEMA_TESTS ) - add_test( NAME generate_cpp_${PROJECT_NAME} +macro(SCHEMA_TESTS) + add_test(NAME generate_cpp_${PROJECT_NAME} WORKING_DIRECTORY ${CMAKE_BINARY_DIR} COMMAND ${CMAKE_COMMAND} --build . --target generate_cpp_${PROJECT_NAME} - --config $ ) - set_tests_properties( generate_cpp_${PROJECT_NAME} PROPERTIES LABELS cpp_schema_gen ) - add_test( NAME build_cpp_${PROJECT_NAME} + --config $) + set_tests_properties(generate_cpp_${PROJECT_NAME} PROPERTIES LABELS cpp_schema_gen) + add_test(NAME build_cpp_${PROJECT_NAME} WORKING_DIRECTORY ${CMAKE_BINARY_DIR} COMMAND ${CMAKE_COMMAND} --build . --target p21read_${PROJECT_NAME} - --config $ ) - set_tests_properties( build_cpp_${PROJECT_NAME} PROPERTIES DEPENDS generate_cpp_${PROJECT_NAME} LABELS cpp_schema_build ) + --config $) + set_tests_properties(build_cpp_${PROJECT_NAME} PROPERTIES DEPENDS generate_cpp_${PROJECT_NAME} LABELS cpp_schema_build) if(NOT WIN32) - add_test( NAME build_lazy_cpp_${PROJECT_NAME} + add_test(NAME build_lazy_cpp_${PROJECT_NAME} WORKING_DIRECTORY ${CMAKE_BINARY_DIR} COMMAND ${CMAKE_COMMAND} --build . --target lazy_${PROJECT_NAME} - --config $ ) - set_tests_properties( build_lazy_cpp_${PROJECT_NAME} PROPERTIES DEPENDS generate_cpp_${PROJECT_NAME} LABELS cpp_schema_build ) + --config $) + set_tests_properties(build_lazy_cpp_${PROJECT_NAME} PROPERTIES DEPENDS generate_cpp_${PROJECT_NAME} LABELS cpp_schema_build) endif(NOT WIN32) -ENDMACRO( SCHEMA_TESTS ) +endmacro(SCHEMA_TESTS) # SCHEMA_TARGETS macro - # expFile: path to express file @@ -76,36 +76,36 @@ ENDMACRO( SCHEMA_TESTS ) # # create targets for the schema(s) in expFile # targets include gen_cxx_*, sdai_cxx_*, p21read_*, lazyp21_*, ... -MACRO( SCHEMA_TARGETS expFile schemaName sourceFiles ) - # schema scanner comes up with a short schema name for PROJECT() ( which sets ${PROJECT_NAME} ) - message( STATUS "Will generate ${${PROJECT_NAME}_file_count} C++ files for ${PROJECT_NAME}.") +macro(SCHEMA_TARGETS expFile schemaName sourceFiles) + # schema scanner comes up with a short schema name for PROJECT() (which sets ${PROJECT_NAME}) + message(STATUS "Will generate ${${PROJECT_NAME}_file_count} C++ files for ${PROJECT_NAME}.") - add_custom_target( generate_cpp_${PROJECT_NAME} DEPENDS exp2cxx ${expFile} ${sourceFiles} SOURCES ${sourceFiles} ) + add_custom_target(generate_cpp_${PROJECT_NAME} DEPENDS exp2cxx ${expFile} ${sourceFiles} SOURCES ${sourceFiles}) # this calls a cmake script because it doesn't seem to be possible # to divert stdout, stderr in cmake except via execute_process - add_custom_command( OUTPUT ${sourceFiles} + add_custom_command(OUTPUT ${sourceFiles} COMMAND ${CMAKE_COMMAND} -DEXE=\"$\" -DEXP=\"${expFile}\" -DONESHOT=\"${SC_GENERATE_CXX_ONESHOT}\" -DSDIR=\"${CMAKE_CURRENT_LIST_DIR}\" -P ${SC_CMAKE_DIR}/SC_Run_exp2cxx.cmake WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} COMMENT "[exp2cxx] Generating ${${PROJECT_NAME}_file_count} C++ files for ${PROJECT_NAME}." - ) + ) # will include_directories behave as desired in a macro? include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ${SC_SOURCE_DIR}/src/cldai ${SC_SOURCE_DIR}/src/cleditor ${SC_SOURCE_DIR}/src/clutils ${SC_SOURCE_DIR}/src/clstepcore ${SC_SOURCE_DIR}/src/base ${SC_SOURCE_DIR}/src/base/judy/src - ) + ) # if testing is enabled, "TESTABLE" sets property EXCLUDE_FROM_ALL and prevents installation - SC_ADDLIB( ${PROJECT_NAME} "${sourceFiles}" "stepdai;stepcore;stepeditor;steputils;base" "TESTABLE" ) - add_dependencies( ${PROJECT_NAME} generate_cpp_${PROJECT_NAME} ) + SC_ADDLIB(${PROJECT_NAME} "${sourceFiles}" "stepdai;stepcore;stepeditor;steputils;base" "TESTABLE") + add_dependencies(${PROJECT_NAME} generate_cpp_${PROJECT_NAME}) SCHEMA_TESTS() - P21_TESTS( ${expFile} ) + P21_TESTS(${expFile}) # TODO add test to verify that schema scanner output matches fedex_plus output -ENDMACRO( SCHEMA_TARGETS expFile schemaName sourceFiles ) +endmacro(SCHEMA_TARGETS expFile schemaName sourceFiles) # Local Variables: # tab-width: 8 diff --git a/cmake/SC_Config_Headers.cmake b/cmake/SC_Config_Headers.cmake index 8c6b46c5..ceb4125f 100644 --- a/cmake/SC_Config_Headers.cmake +++ b/cmake/SC_Config_Headers.cmake @@ -3,7 +3,7 @@ # Take the sc config file template as the starting point for # sc_cf.h.in - scripts may need to append to the template, so # it is read into memory initially. -SET(CONFIG_H_FILE ${SC_BINARY_DIR}/include/sc_cf.h.in) +set(CONFIG_H_FILE ${SC_BINARY_DIR}/include/sc_cf.h.in) set_source_files_properties(${CONFIG_H_FILE} PROPERTIES GENERATED TRUE) set(CMAKE_CURRENT_PROJECT SC) define_property(GLOBAL PROPERTY SC_CONFIG_H_CONTENTS BRIEF_DOCS "config.h.in contents" FULL_DOCS "config.h.in contents for SC project") @@ -19,12 +19,12 @@ endif(NOT COMMAND CONFIG_H_APPEND) file(READ ${SC_SOURCE_DIR}/include/sc_cf_cmake.h.in CONFIG_H_FILE_CONTENTS) CONFIG_H_APPEND(SC "${CONFIG_H_FILE_CONTENTS}") -INCLUDE(CheckLibraryExists) -INCLUDE(CheckIncludeFile) -INCLUDE(CheckFunctionExists) -INCLUDE(CheckTypeSize) -INCLUDE(CMakePushCheckState) -INCLUDE(CheckCXXSourceRuns) +include(CheckLibraryExists) +include(CheckIncludeFile) +include(CheckFunctionExists) +include(CheckTypeSize) +include(CMakePushCheckState) +include(CheckCXXSourceRuns) CHECK_INCLUDE_FILE(ndir.h HAVE_NDIR_H) CHECK_INCLUDE_FILE(stdarg.h HAVE_STDARG_H) diff --git a/cmake/SC_Locale.cmake b/cmake/SC_Locale.cmake index 4d1cae2f..f04a5865 100644 --- a/cmake/SC_Locale.cmake +++ b/cmake/SC_Locale.cmake @@ -1,17 +1,17 @@ # Save the current LC_ALL, LC_MESSAGES, and LANG environment variables and set them # to "C" so things like date output are as expected -SET(_orig_lc_all $ENV{LC_ALL}) -SET(_orig_lc_messages $ENV{LC_MESSAGES}) -SET(_orig_lang $ENV{LANG}) -IF(_orig_lc_all) - SET(ENV{LC_ALL} C) -ENDIF(_orig_lc_all) -IF(_orig_lc_messages) - SET(ENV{LC_MESSAGES} C) -ENDIF(_orig_lc_messages) -IF(_orig_lang) - SET(ENV{LANG} C) -ENDIF(_orig_lang) +set(_orig_lc_all $ENV{LC_ALL}) +set(_orig_lc_messages $ENV{LC_MESSAGES}) +set(_orig_lang $ENV{LANG}) +if(_orig_lc_all) + set(ENV{LC_ALL} C) +endif(_orig_lc_all) +if(_orig_lc_messages) + set(ENV{LC_MESSAGES} C) +endif(_orig_lc_messages) +if(_orig_lang) + set(ENV{LANG} C) +endif(_orig_lang) # Local Variables: # tab-width: 8 diff --git a/cmake/SC_Outdirs.cmake b/cmake/SC_Outdirs.cmake index 181ff8f7..49547d01 100644 --- a/cmake/SC_Outdirs.cmake +++ b/cmake/SC_Outdirs.cmake @@ -1,25 +1,25 @@ # in its own file so that it can be used by the schema scanner as well -IF(NOT DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY) - SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${SC_BINARY_DIR}/lib CACHE INTERNAL "Single output directory for building all libraries.") -ENDIF(NOT DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY) -IF(NOT DEFINED CMAKE_ARCHIVE_OUTPUT_DIRECTORY) - SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${SC_BINARY_DIR}/lib CACHE INTERNAL "Single output directory for building all archives.") -ENDIF(NOT DEFINED CMAKE_ARCHIVE_OUTPUT_DIRECTORY) -IF(NOT DEFINED CMAKE_RUNTIME_OUTPUT_DIRECTORY) - SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${SC_BINARY_DIR}/bin CACHE INTERNAL "Single output directory for building all executables.") -ENDIF(NOT DEFINED CMAKE_RUNTIME_OUTPUT_DIRECTORY) -FOREACH(CFG_TYPE ${CMAKE_CONFIGURATION_TYPES}) - STRING(TOUPPER "${CFG_TYPE}" CFG_TYPE) - IF(NOT "CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CFG_TYPE}") - SET("CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CFG_TYPE}" ${SC_BINARY_DIR}/lib CACHE INTERNAL "Single output directory for building all libraries.") - ENDIF(NOT "CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CFG_TYPE}") - IF(NOT "CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CFG_TYPE}") - SET("CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CFG_TYPE}" ${SC_BINARY_DIR}/lib CACHE INTERNAL "Single output directory for building all archives.") - ENDIF(NOT "CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CFG_TYPE}") - IF(NOT "CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CFG_TYPE}") - SET("CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CFG_TYPE}" ${SC_BINARY_DIR}/bin CACHE INTERNAL "Single output directory for building all executables.") - ENDIF(NOT "CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CFG_TYPE}") -ENDFOREACH() +if(NOT DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY) + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${SC_BINARY_DIR}/lib CACHE INTERNAL "Single output directory for building all libraries.") +endif(NOT DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY) +if(NOT DEFINED CMAKE_ARCHIVE_OUTPUT_DIRECTORY) + set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${SC_BINARY_DIR}/lib CACHE INTERNAL "Single output directory for building all archives.") +endif(NOT DEFINED CMAKE_ARCHIVE_OUTPUT_DIRECTORY) +if(NOT DEFINED CMAKE_RUNTIME_OUTPUT_DIRECTORY) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${SC_BINARY_DIR}/bin CACHE INTERNAL "Single output directory for building all executables.") +endif(NOT DEFINED CMAKE_RUNTIME_OUTPUT_DIRECTORY) +foreach(CFG_TYPE ${CMAKE_CONFIGURATION_TYPES}) + string(TOUPPER "${CFG_TYPE}" CFG_TYPE) + if(NOT "CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CFG_TYPE}") + set("CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CFG_TYPE}" ${SC_BINARY_DIR}/lib CACHE INTERNAL "Single output directory for building all libraries.") + endif(NOT "CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CFG_TYPE}") + if(NOT "CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CFG_TYPE}") + set("CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CFG_TYPE}" ${SC_BINARY_DIR}/lib CACHE INTERNAL "Single output directory for building all archives.") + endif(NOT "CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CFG_TYPE}") + if(NOT "CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CFG_TYPE}") + set("CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CFG_TYPE}" ${SC_BINARY_DIR}/bin CACHE INTERNAL "Single output directory for building all executables.") + endif(NOT "CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CFG_TYPE}") +endforeach() # Local Variables: # tab-width: 8 diff --git a/cmake/SC_Paths.cmake b/cmake/SC_Paths.cmake index afd81509..b053ebd1 100644 --- a/cmake/SC_Paths.cmake +++ b/cmake/SC_Paths.cmake @@ -1,4 +1,4 @@ -MACRO(RELATIVE_PATH_TO_TOPLEVEL current_dir rel_path) +macro(RELATIVE_PATH_TO_TOPLEVEL current_dir rel_path) string(REPLACE "${SC_SOURCE_DIR}" "" subpath "${current_dir}") string(REGEX REPLACE "^/" "" subpath "${subpath}") string(LENGTH "${subpath}" PATH_LENGTH) @@ -12,27 +12,27 @@ MACRO(RELATIVE_PATH_TO_TOPLEVEL current_dir rel_path) string(LENGTH "${subpath}" PATH_LENGTH) endwhile(PATH_LENGTH GREATER 0) endif(PATH_LENGTH GREATER 0) -ENDMACRO(RELATIVE_PATH_TO_TOPLEVEL current_dir rel_path) +endmacro(RELATIVE_PATH_TO_TOPLEVEL current_dir rel_path) -MACRO( LOCATE_SCHEMA SCHEMA_FILE _res_var ) - if( EXISTS "${CMAKE_BINARY_DIR}/${SCHEMA_FILE}" ) #is it a path relative to build dir? - set( ${_res_var} "${CMAKE_BINARY_DIR}/${SCHEMA_FILE}" ) - elseif( EXISTS "${SC_SOURCE_DIR}/data/${SCHEMA_FILE}" ) # path relative to STEPcode/data? - set( ${_res_var} "${SC_SOURCE_DIR}/data/${SCHEMA_FILE}" ) - elseif( EXISTS ${SCHEMA_FILE} ) # already an absolute path - set( ${_res_var} ${SCHEMA_FILE} ) +macro(LOCATE_SCHEMA SCHEMA_FILE _res_var) + if(EXISTS "${CMAKE_BINARY_DIR}/${SCHEMA_FILE}") #is it a path relative to build dir? + set(${_res_var} "${CMAKE_BINARY_DIR}/${SCHEMA_FILE}") + elseif(EXISTS "${SC_SOURCE_DIR}/data/${SCHEMA_FILE}") # path relative to STEPcode/data? + set(${_res_var} "${SC_SOURCE_DIR}/data/${SCHEMA_FILE}") + elseif(EXISTS ${SCHEMA_FILE}) # already an absolute path + set(${_res_var} ${SCHEMA_FILE}) else() - message( FATAL_ERROR "Cannot find ${CMAKE_BINARY_DIR}/${SCHEMA_FILE} or ${SC_SOURCE_DIR}/data/${SCHEMA_FILE}/*.exp or ${SCHEMA_FILE}" ) + message(FATAL_ERROR "Cannot find ${CMAKE_BINARY_DIR}/${SCHEMA_FILE} or ${SC_SOURCE_DIR}/data/${SCHEMA_FILE}/*.exp or ${SCHEMA_FILE}") endif() - if( IS_DIRECTORY ${${_res_var}} ) #if it is a dir, look for one .exp file inside - file(GLOB ${_res_var} ${${_res_var}}/*.exp ) + if(IS_DIRECTORY ${${_res_var}}) #if it is a dir, look for one .exp file inside + file(GLOB ${_res_var} ${${_res_var}}/*.exp) endif() - if( NOT EXISTS ${${_res_var}} ) + if(NOT EXISTS ${${_res_var}}) message(FATAL_ERROR "Expected one express file. Found '${${_res_var}}' instead.") endif() -ENDMACRO( LOCATE_SCHEMA SCHEMA_FILE _res_var ) +endmacro(LOCATE_SCHEMA SCHEMA_FILE _res_var) # Local Variables: # tab-width: 8 diff --git a/cmake/SC_Run_exp2cxx.cmake b/cmake/SC_Run_exp2cxx.cmake index aba91fe6..dc4111f0 100644 --- a/cmake/SC_Run_exp2cxx.cmake +++ b/cmake/SC_Run_exp2cxx.cmake @@ -1,18 +1,18 @@ # if oneshot is true, don't run exp2cxx if source files exist. if schema.cc exists, assume others do -if( ONESHOT AND EXISTS "${SDIR}/schema.cc" ) - message( "WARNING: SC_GENERATE_CXX_ONESHOT is enabled. If generated code has been modified, it will NOT be rewritten!" ) - message( "This is ONLY for debugging STEPcode internals!" ) +if(ONESHOT AND EXISTS "${SDIR}/schema.cc") + message("WARNING: SC_GENERATE_CXX_ONESHOT is enabled. If generated code has been modified, it will NOT be rewritten!") + message("This is ONLY for debugging STEPcode internals!") else() - execute_process( COMMAND ${EXE} ${EXP} + execute_process(COMMAND ${EXE} ${EXP} WORKING_DIRECTORY ${SDIR} RESULT_VARIABLE _res OUTPUT_FILE exp2cxx_stdout.txt ERROR_FILE exp2cxx_stderr.txt - ) - if( NOT "${_res}" STREQUAL "0" ) - message( FATAL_ERROR "${EXE} reported an error for ${EXP}.\nsee exp2cxx_stdout.txt and exp2cxx_stderr.txt in ${SDIR} for details." ) - endif( NOT "${_res}" STREQUAL "0" ) + ) + if(NOT "${_res}" STREQUAL "0") + message(FATAL_ERROR "${EXE} reported an error for ${EXP}.\nsee exp2cxx_stdout.txt and exp2cxx_stderr.txt in ${SDIR} for details.") + endif(NOT "${_res}" STREQUAL "0") # TODO count number of lines in stdout/stderr and tell user? endif() diff --git a/cmake/SC_Targets.cmake b/cmake/SC_Targets.cmake index fcb221cd..e4bd29c0 100644 --- a/cmake/SC_Targets.cmake +++ b/cmake/SC_Targets.cmake @@ -1,13 +1,13 @@ # set compile definitions for dll exports on windows -MACRO(DEFINE_DLL_EXPORTS libname) +macro(DEFINE_DLL_EXPORTS libname) if(MSVC OR BORLAND) if(${libname} MATCHES "sdai_.*") set(export "SC_SCHEMA_DLL_EXPORTS") else() - STRING(REGEX REPLACE "lib" "" shortname "${libname}") - STRING(REGEX REPLACE "step" "" LOWERCORE "${shortname}") - STRING(TOUPPER ${LOWERCORE} UPPER_CORE) + string(REGEX REPLACE "lib" "" shortname "${libname}") + string(REGEX REPLACE "step" "" LOWERCORE "${shortname}") + string(TOUPPER ${LOWERCORE} UPPER_CORE) set(export "SC_${UPPER_CORE}_DLL_EXPORTS") endif() get_target_property(defs ${libname} COMPILE_DEFINITIONS) @@ -21,16 +21,16 @@ MACRO(DEFINE_DLL_EXPORTS libname) endmacro(DEFINE_DLL_EXPORTS libname) # set compile definitions for dll imports on windows -MACRO(DEFINE_DLL_IMPORTS tgt libs) +macro(DEFINE_DLL_IMPORTS tgt libs) if(MSVC OR BORLAND) get_target_property(defs ${tgt} COMPILE_DEFINITIONS) if(NOT defs) #if no properties, ${defs} will be defs-NOTFOUND which CMake interprets as false set(defs "") endif(NOT defs) foreach(lib ${libs}) - STRING(REGEX REPLACE "lib" "" shortname "${lib}") - STRING(REGEX REPLACE "step" "" LOWERCORE "${shortname}") - STRING(TOUPPER ${LOWERCORE} UPPER_CORE) + string(REGEX REPLACE "lib" "" shortname "${lib}") + string(REGEX REPLACE "step" "" LOWERCORE "${shortname}") + string(TOUPPER ${LOWERCORE} UPPER_CORE) list(APPEND defs "SC_${UPPER_CORE}_DLL_IMPORTS") endforeach(lib ${libs}) if(DEFINED defs) @@ -46,7 +46,7 @@ endmacro(DEFINE_DLL_IMPORTS tgt libs) # in which case the EXCLUDE_FROM_ALL property is set for testing. # EXCLUDE_FROM_ALL cannot be set on targets that are to be installed, # so either test the target or install it - but not both -MACRO(EXCLUDE_OR_INSTALL target dest arg_3) +macro(EXCLUDE_OR_INSTALL target dest arg_3) if(NOT ((SC_ENABLE_TESTING) AND ("${arg_3}" STREQUAL "TESTABLE"))) INSTALL(TARGETS ${target} DESTINATION ${dest}) else(NOT ((SC_ENABLE_TESTING) AND ("${arg_3}" STREQUAL "TESTABLE"))) @@ -102,7 +102,7 @@ endmacro(SC_ADDEXEC execname srcslist libslist) # optional args can also be used by MSVC-specific code, but it looks like these two uses # will not conflict because the MSVC args must contain "STRICT" macro(SC_ADDLIB libname srcslist libslist) - STRING(REGEX REPLACE "-framework;" "-framework " libslist "${libslist1}") + string(REGEX REPLACE "-framework;" "-framework " libslist "${libslist1}") if(SC_BUILD_SHARED_LIBS) add_library(${libname} SHARED ${srcslist}) DEFINE_DLL_EXPORTS(${libname}) diff --git a/cmake/cmake_uninstall.cmake.in b/cmake/cmake_uninstall.cmake.in index c8387c8c..d0c1ade3 100644 --- a/cmake/cmake_uninstall.cmake.in +++ b/cmake/cmake_uninstall.cmake.in @@ -1,22 +1,30 @@ if (NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") - message(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"") + message(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"") endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) string(REGEX REPLACE "\n" ";" files "${files}") list(REVERSE files) foreach (file ${files}) - message(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"") - if (EXISTS "$ENV{DESTDIR}${file}") - execute_process( - COMMAND ${CMAKE_COMMAND} -E remove "$ENV{DESTDIR}${file}" - OUTPUT_VARIABLE rm_out - RESULT_VARIABLE rm_retval - ) - if(NOT ${rm_retval} EQUAL 0) - message(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"") - endif (NOT ${rm_retval} EQUAL 0) - else (EXISTS "$ENV{DESTDIR}${file}") - message(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.") - endif (EXISTS "$ENV{DESTDIR}${file}") -endforeach(file) \ No newline at end of file + message(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"") + if (EXISTS "$ENV{DESTDIR}${file}") + execute_process( + COMMAND ${CMAKE_COMMAND} -E remove "$ENV{DESTDIR}${file}" + OUTPUT_VARIABLE rm_out + RESULT_VARIABLE rm_retval + ) + if(NOT ${rm_retval} EQUAL 0) + message(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"") + endif (NOT ${rm_retval} EQUAL 0) + else (EXISTS "$ENV{DESTDIR}${file}") + message(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.") + endif (EXISTS "$ENV{DESTDIR}${file}") +endforeach(file) + +# Local Variables: +# tab-width: 8 +# mode: cmake +# indent-tabs-mode: t +# End: +# ex: shiftwidth=2 tabstop=8 + diff --git a/cmake/sc_version_string.cmake b/cmake/sc_version_string.cmake index 755d94b6..40e73a7c 100644 --- a/cmake/sc_version_string.cmake +++ b/cmake/sc_version_string.cmake @@ -4,7 +4,6 @@ # http://stackoverflow.com/questions/3780667 # http://www.cmake.org/pipermail/cmake/2009-February/027014.html - set(SC_IS_SUBBUILD "@SC_IS_SUBBUILD@") #---------- find commit id ------------------ @@ -13,50 +12,50 @@ set(SC_IS_SUBBUILD "@SC_IS_SUBBUILD@") #create a tag with 'git tag ' and 'git push --tags' #if git can't be found, uses contents of SC_VERSION.txt -set(VERS_FILE ${SOURCE_DIR}/SC_VERSION.txt ) -if( EXISTS ${SOURCE_DIR}/.git ) +set(VERS_FILE ${SOURCE_DIR}/SC_VERSION.txt) +if(EXISTS ${SOURCE_DIR}/.git) find_package(Git QUIET) if(GIT_FOUND) execute_process(COMMAND ${GIT_EXECUTABLE} describe --tags WORKING_DIRECTORY ${SOURCE_DIR} - RESULT_VARIABLE res_var OUTPUT_VARIABLE GIT_COMMIT_ID ) - if( NOT ${res_var} EQUAL 0 ) - file( READ ${VERS_FILE} GIT_COMMIT_ID LIMIT 255 ) + RESULT_VARIABLE res_var OUTPUT_VARIABLE GIT_COMMIT_ID) + if(NOT ${res_var} EQUAL 0) + file(READ ${VERS_FILE} GIT_COMMIT_ID LIMIT 255) if(NOT SC_IS_SUBBUILD) - message( WARNING "Git failed (probably no tags in repo). Build will contain revision info from ${VERS_FILE}." ) + message(WARNING "Git failed (probably no tags in repo). Build will contain revision info from ${VERS_FILE}.") endif(NOT SC_IS_SUBBUILD) endif() else(GIT_FOUND) - file( READ ${VERS_FILE} GIT_COMMIT_ID LIMIT 255 ) + file(READ ${VERS_FILE} GIT_COMMIT_ID LIMIT 255) if(NOT SC_IS_SUBBUILD) - message( WARNING "Git not found. Build will contain revision info from ${VERS_FILE}." ) + message(WARNING "Git not found. Build will contain revision info from ${VERS_FILE}.") endif(NOT SC_IS_SUBBUILD) endif(GIT_FOUND) else() - file( READ ${VERS_FILE} GIT_COMMIT_ID LIMIT 255 ) + file(READ ${VERS_FILE} GIT_COMMIT_ID LIMIT 255) if(NOT SC_IS_SUBBUILD) - message( WARNING "Git failed ('.git' not found). Build will contain revision info from ${VERS_FILE}." ) + message(WARNING "Git failed ('.git' not found). Build will contain revision info from ${VERS_FILE}.") endif(NOT SC_IS_SUBBUILD) endif() -string( REPLACE "\n" "" GIT_COMMIT_ID ${GIT_COMMIT_ID} ) +string(REPLACE "\n" "" GIT_COMMIT_ID ${GIT_COMMIT_ID}) #-------------- date and time --------------- #once cmake_minimum_required is >= 2.8.11, we can use TIMESTAMP: -#string( TIMESTAMP date_time_string ) +#string(TIMESTAMP date_time_string) -if( UNIX ) - execute_process( COMMAND date "+%d %b %Y %H:%M" OUTPUT_VARIABLE date_time_string OUTPUT_STRIP_TRAILING_WHITESPACE ) -elseif( WIN32 ) - execute_process( COMMAND cmd /c date /t OUTPUT_VARIABLE currentDate OUTPUT_STRIP_TRAILING_WHITESPACE ) - execute_process( COMMAND cmd /c time /t OUTPUT_VARIABLE currentTime OUTPUT_STRIP_TRAILING_WHITESPACE ) - set ( date_time_string "${currentDate} ${currentTime}" ) +if(UNIX) + execute_process(COMMAND date "+%d %b %Y %H:%M" OUTPUT_VARIABLE date_time_string OUTPUT_STRIP_TRAILING_WHITESPACE) +elseif(WIN32) + execute_process(COMMAND cmd /c date /t OUTPUT_VARIABLE currentDate OUTPUT_STRIP_TRAILING_WHITESPACE) + execute_process(COMMAND cmd /c time /t OUTPUT_VARIABLE currentTime OUTPUT_STRIP_TRAILING_WHITESPACE) + set (date_time_string "${currentDate} ${currentTime}") else() - set( date_time_string "\" __DATE__ \" \" __TIME__ \" " ) - if( NOT SC_IS_SUBBUILD ) - message( STATUS "Unknown platform - using date from preprocessor" ) - endif( NOT SC_IS_SUBBUILD ) + set(date_time_string "\" __DATE__ \" \" __TIME__ \" ") + if(NOT SC_IS_SUBBUILD) + message(STATUS "Unknown platform - using date from preprocessor") + endif(NOT SC_IS_SUBBUILD) endif() -set( header_string "/* sc_version_string.h - written by cmake. Changes will be lost! */\n" +set(header_string "/* sc_version_string.h - written by cmake. Changes will be lost! */\n" "#ifndef SC_VERSION_STRING\n" "#define SC_VERSION_STRING\n\n" "/*\n** The git commit id looks like \"test-1-g5e1fb47\", where test is the\n" @@ -68,9 +67,9 @@ set( header_string "/* sc_version_string.h - written by cmake. Changes will be l " \"git commit id: ${GIT_COMMIT_ID}, build timestamp ${date_time_string}\"\n" "}\;\n\n" "#endif\n" - ) + ) -file(WRITE sc_version_string.h.txt ${header_string} ) +file(WRITE sc_version_string.h.txt ${header_string}) # copy the file to the final header only if the version changes # reduces needless rebuilds execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different diff --git a/cmake/schema_scanner/CMakeLists.txt b/cmake/schema_scanner/CMakeLists.txt index 957dbc90..13bbb24d 100644 --- a/cmake/schema_scanner/CMakeLists.txt +++ b/cmake/schema_scanner/CMakeLists.txt @@ -1,21 +1,21 @@ -PROJECT( SC_SUBPROJECT_SCHEMA_SCANNER ) -CMAKE_MINIMUM_REQUIRED( VERSION 2.8.7 ) +project(SC_SUBPROJECT_SCHEMA_SCANNER) +cmake_minimum_required(VERSION 2.8.7) -if( NOT ( "${CALLED_FROM}" STREQUAL "STEPCODE_CMAKELISTS" AND DEFINED SC_ROOT AND DEFINED SC_BUILDDIR ) ) +if(NOT ("${CALLED_FROM}" STREQUAL "STEPCODE_CMAKELISTS" AND DEFINED SC_ROOT AND DEFINED SC_BUILDDIR)) message(" ${CALLED_FROM} ${SC_ROOT} ${SC_BUILDDIR}") - message( FATAL_ERROR "This is not a truly independent project; it should be built during the STEPcode configuration stage." ) + message(FATAL_ERROR "This is not a truly independent project; it should be built during the STEPcode configuration stage.") endif() # SC_ROOT: SC root dir # SC_BUILDDIR: SC build dir, so generated headers can be found -set( CMAKE_BUILD_TYPE Debug ) +set(CMAKE_BUILD_TYPE Debug) # set all target location variables so that MSVC will put the executable the same place as other compilers -set( SC_BINARY_DIR ${SC_BUILDDIR} ) -include( ${CMAKE_CURRENT_SOURCE_DIR}/../SC_Outdirs.cmake ) +set(SC_BINARY_DIR ${SC_BUILDDIR}) +include(${CMAKE_CURRENT_SOURCE_DIR}/../SC_Outdirs.cmake) -set( schema_scanner_src +set(schema_scanner_src ${SC_ROOT}/src/base/sc_mkdir.c ${SC_ROOT}/src/exp2cxx/genCxxFilenames.c ${SC_ROOT}/src/exp2cxx/class_strings.c @@ -43,7 +43,7 @@ set( schema_scanner_src ${SC_ROOT}/src/express/type.c ${SC_ROOT}/src/express/variable.c ${CMAKE_CURRENT_SOURCE_DIR}/schemaScanner.cc - ) + ) include_directories( ${SC_ROOT}/include/ @@ -52,21 +52,21 @@ include_directories( ${SC_ROOT}/src/base ${SC_ROOT}/src/exp2cxx ${SC_BUILDDIR}/include - ) + ) if(MSVC) - add_definitions( -D__MSVC__ -D__WIN32__ ) + add_definitions(-D__MSVC__ -D__WIN32__) # Disable warning for preferred usage of secure functions (example strcpy should be strcpy_s, ...) - add_definitions( -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS ) + add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS) elseif(BORLAND) - add_definitions( -D__BORLAND__ -D__WIN32__ ) + add_definitions(-D__BORLAND__ -D__WIN32__) else() - add_definitions( -pedantic -W -Wall -Wundef -Wfloat-equal -Wshadow -Winline -Wno-long-long ) + add_definitions(-pedantic -W -Wall -Wundef -Wfloat-equal -Wshadow -Winline -Wno-long-long) endif() -add_definitions( -DSCHEMA_SCANNER ) +add_definitions(-DSCHEMA_SCANNER) -add_executable( schema_scanner ${schema_scanner_src} ) +add_executable(schema_scanner ${schema_scanner_src}) # Local Variables: # tab-width: 8 diff --git a/cmake/schema_scanner/schemaScanner.cmake b/cmake/schema_scanner/schemaScanner.cmake index b6c3e109..597b5330 100644 --- a/cmake/schema_scanner/schemaScanner.cmake +++ b/cmake/schema_scanner/schemaScanner.cmake @@ -16,74 +16,74 @@ # SCANNER_OUT_DIR: location of binary, same dir as SC uses # SCANNER_BUILD_DIR: location scanner is built -set( SCANNER_SRC_DIR ${SC_CMAKE_DIR}/schema_scanner ) -set( SCANNER_BUILD_DIR ${SC_BINARY_DIR}/schema_scanner ) -set( SCANNER_OUT_DIR ${SC_BINARY_DIR}/bin ) +set(SCANNER_SRC_DIR ${SC_CMAKE_DIR}/schema_scanner) +set(SCANNER_BUILD_DIR ${SC_BINARY_DIR}/schema_scanner) +set(SCANNER_OUT_DIR ${SC_BINARY_DIR}/bin) #write a cmake file for the cache. the alternative is a very long # command line - and the command line can't have newlines in it -set( initial_scanner_cache ${SCANNER_BUILD_DIR}/initial_scanner_cache.cmake ) -file( WRITE ${initial_scanner_cache} " -set( SC_ROOT \"${SC_SOURCE_DIR}\" CACHE STRING \"root dir\" ) -set( SC_BUILDDIR \"${SC_BINARY_DIR}\" CACHE PATH \"build dir\" ) -set( CALLED_FROM \"STEPCODE_CMAKELISTS\" CACHE STRING \"verification\" ) -set( CMAKE_BUILD_TYPE \"Debug\" CACHE STRING \"build type\" ) -set( CMAKE_C_COMPILER \"${CMAKE_C_COMPILER}\" CACHE STRING \"compiler\" ) -set( CMAKE_CXX_COMPILER \"${CMAKE_CXX_COMPILER}\" CACHE STRING \"compiler\" ) -" ) +set(initial_scanner_cache ${SCANNER_BUILD_DIR}/initial_scanner_cache.cmake) +file(WRITE ${initial_scanner_cache} " +set(SC_ROOT \"${SC_SOURCE_DIR}\" CACHE STRING \"root dir\") +set(SC_BUILDDIR \"${SC_BINARY_DIR}\" CACHE PATH \"build dir\") +set(CALLED_FROM \"STEPCODE_CMAKELISTS\" CACHE STRING \"verification\") +set(CMAKE_BUILD_TYPE \"Debug\" CACHE STRING \"build type\") +set(CMAKE_C_COMPILER \"${CMAKE_C_COMPILER}\" CACHE STRING \"compiler\") +set(CMAKE_CXX_COMPILER \"${CMAKE_CXX_COMPILER}\" CACHE STRING \"compiler\") +") -message( "-- Compiling schema scanner..." ) +message("-- Compiling schema scanner...") -execute_process( COMMAND ${CMAKE_COMMAND} -E make_directory ${SC_BINARY_DIR}/schemas ) -execute_process( COMMAND ${CMAKE_COMMAND} -E make_directory ${SCANNER_BUILD_DIR} ) -execute_process( COMMAND ${CMAKE_COMMAND} -C ${initial_scanner_cache} ${SCANNER_SRC_DIR} +execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${SC_BINARY_DIR}/schemas) +execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${SCANNER_BUILD_DIR}) +execute_process(COMMAND ${CMAKE_COMMAND} -C ${initial_scanner_cache} ${SCANNER_SRC_DIR} WORKING_DIRECTORY ${SCANNER_BUILD_DIR} TIMEOUT 10 OUTPUT_VARIABLE _ss_config_out RESULT_VARIABLE _ss_config_stat ERROR_VARIABLE _ss_config_err - ) -if( NOT ${_ss_config_stat} STREQUAL "0" ) - message( FATAL_ERROR "Scanner config status: ${_ss_config_stat}. stdout:\n${_ss_config_out}\nstderr:\n${_ss_config_err}" ) -endif( NOT ${_ss_config_stat} STREQUAL "0" ) -execute_process( COMMAND ${CMAKE_COMMAND} --build ${SCANNER_BUILD_DIR} --config Debug --clean-first + ) +if(NOT ${_ss_config_stat} STREQUAL "0") + message(FATAL_ERROR "Scanner config status: ${_ss_config_stat}. stdout:\n${_ss_config_out}\nstderr:\n${_ss_config_err}") +endif(NOT ${_ss_config_stat} STREQUAL "0") +execute_process(COMMAND ${CMAKE_COMMAND} --build ${SCANNER_BUILD_DIR} --config Debug --clean-first WORKING_DIRECTORY ${SCANNER_BUILD_DIR} TIMEOUT 30 # should take far less than 30s OUTPUT_VARIABLE _ss_build_out RESULT_VARIABLE _ss_build_stat ERROR_VARIABLE _ss_build_err - ) -if( NOT ${_ss_build_stat} STREQUAL "0" ) - message( FATAL_ERROR "Scanner build status: ${_ss_build_stat}. stdout:\n${_ss_build_out}\nstderr:\n${_ss_build_err}" ) -endif( NOT ${_ss_build_stat} STREQUAL "0" ) + ) +if(NOT ${_ss_build_stat} STREQUAL "0") + message(FATAL_ERROR "Scanner build status: ${_ss_build_stat}. stdout:\n${_ss_build_out}\nstderr:\n${_ss_build_err}") +endif(NOT ${_ss_build_stat} STREQUAL "0") -message( "-- Schema scanner built. Running it..." ) +message("-- Schema scanner built. Running it...") # not sure if it makes sense to install this or not... -install( PROGRAMS ${SCANNER_OUT_DIR}/schema_scanner DESTINATION ${BIN_INSTALL_DIR} ) +install(PROGRAMS ${SCANNER_OUT_DIR}/schema_scanner DESTINATION ${BIN_INSTALL_DIR}) # macro SCHEMA_CMLIST # runs the schema scanner on one express file, creating a CMakeLists.txt file for each schema found. Those files are added via add_subdirectory(). # # SCHEMA_FILE - path to the schema # TODO should we have a result variable to return schema name(s) found? -MACRO( SCHEMA_CMLIST SCHEMA_FILE ) - execute_process( COMMAND ${SCANNER_OUT_DIR}/schema_scanner ${SCHEMA_FILE} +macro(SCHEMA_CMLIST SCHEMA_FILE) + execute_process(COMMAND ${SCANNER_OUT_DIR}/schema_scanner ${SCHEMA_FILE} WORKING_DIRECTORY ${SC_BINARY_DIR}/schemas RESULT_VARIABLE _ss_stat OUTPUT_VARIABLE _ss_out ERROR_VARIABLE _ss_err - ) - if( NOT "${_ss_stat}" STREQUAL "0" ) + ) + if(NOT "${_ss_stat}" STREQUAL "0") #check size of output, put in file if large? - message( FATAL_ERROR "Schema scan exited with error code ${_ss_stat}. stdout:\n${_ss_out}\nstderr:\n${_ss_err}" ) - endif( NOT "${_ss_stat}" STREQUAL "0" ) + message(FATAL_ERROR "Schema scan exited with error code ${_ss_stat}. stdout:\n${_ss_out}\nstderr:\n${_ss_err}") + endif(NOT "${_ss_stat}" STREQUAL "0") # scanner output format: each line contains an absolute path. each path is a dir containing a CMakeLists for one schema # there will usually be a single line of output, but it is not illegal for multiple schemas to exist in one .exp file - string( STRIP "${_ss_out}" _ss_stripped ) - string( REGEX REPLACE "\\\n" ";" _list ${_ss_stripped} ) - foreach( _dir ${_list} ) - add_subdirectory( ${_dir} ${_dir} ) #specify source and binary dirs as the same - endforeach( _dir ${_ss_out} ) - configure_file( ${SCHEMA_FILE} ${SCANNER_BUILD_DIR}/${_schema} ) #if multiple schemas in one file, _schema is the last one printed. -ENDMACRO( SCHEMA_CMLIST SCHEMA_FILE ) + string(STRIP "${_ss_out}" _ss_stripped) + string(REGEX REPLACE "\\\n" ";" _list ${_ss_stripped}) + foreach(_dir ${_list}) + add_subdirectory(${_dir} ${_dir}) #specify source and binary dirs as the same + endforeach(_dir ${_ss_out}) + configure_file(${SCHEMA_FILE} ${SCANNER_BUILD_DIR}/${_schema}) #if multiple schemas in one file, _schema is the last one printed. +endmacro(SCHEMA_CMLIST SCHEMA_FILE) diff --git a/cmake/sync_generated.cmake.in b/cmake/sync_generated.cmake.in index 17f3d16d..aa51ab51 100644 --- a/cmake/sync_generated.cmake.in +++ b/cmake/sync_generated.cmake.in @@ -69,8 +69,8 @@ if(NOT DEBUGGING_GENERATED_SOURCES) endforeach(outf ${output_files}) endif(NOT LOCKED_SOURCE_DIR) -else (NOT DEBUGGING_GENERATED_SOURCES) - +else(NOT DEBUGGING_GENERATED_SOURCES) + message("\nNote: DEBUGGING_GENERATED_SOURCES is enabled - generated outputs will contain configuration-specific debugging information, so syncing cached output files is not possible. To restore normal behavior, disable DEBUGGING_GENERATED_SOURCES.\n") endif(NOT DEBUGGING_GENERATED_SOURCES) diff --git a/cmake/verify_generated.cmake.in b/cmake/verify_generated.cmake.in index ac4496ab..818975f5 100644 --- a/cmake/verify_generated.cmake.in +++ b/cmake/verify_generated.cmake.in @@ -20,7 +20,7 @@ if(NOT DEBUGGING_GENERATED_SOURCES) message(FATAL_ERROR "Generated sources have been modified. These files should never be modified directly except when debugging faulty output from the generators - changes to lexer and parser logic should be made to the generator input files. If this is a debugging situation, set the variable DEBUGGING_GENERATED_SOURCES to ON during the CMake configure.") endif(srcs_pass) - # If we got by that test, see if it looks like these + # If we got by that test, see if it looks like these # sources came from the current input files. It's not # a failure condition if they didn't, but warn about it. set(filelist "@INPUT_FILELIST@")