diff --git a/CMakeLists.txt b/CMakeLists.txt index 625c34051..6c4567e8d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,18 +5,19 @@ IF(CMAKE_SYSTEM MATCHES "OSF1-V.*") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -timplicit_local -no_implicit_include ") ENDIF(NOT CMAKE_COMPILER_IS_GNUCXX) ENDIF(CMAKE_SYSTEM MATCHES "OSF1-V.*") - SUBDIRS(Source Modules Templates Utilities) ENABLE_TESTING() # Include the standard Dart testing module INCLUDE (${CMake_SOURCE_DIR}/Modules/Dart.cmake) INCLUDE (${CMAKE_BINARY_DIR}/Source/InitialConfigureFlags.cmake OPTIONAL) + IF(CMAKE_CONFIGURE_INSTALL_PREFIX) SET(CMAKE_INSTALL_PREFIX ${CMAKE_CONFIGURE_INSTALL_PREFIX} ) ENDIF(CMAKE_CONFIGURE_INSTALL_PREFIX) # use the ansi CXX compile flag for building cmake + IF (CMAKE_ANSI_CXXFLAGS) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_ANSI_CXXFLAGS}") ENDIF (CMAKE_ANSI_CXXFLAGS) diff --git a/Modules/CMakeBackwardCompatibilityCXX.cmake b/Modules/CMakeBackwardCompatibilityCXX.cmake index 2ce99cf95..a8e44246d 100644 --- a/Modules/CMakeBackwardCompatibilityCXX.cmake +++ b/Modules/CMakeBackwardCompatibilityCXX.cmake @@ -1,2 +1,10 @@ # INCLUDE(${CMAKE_ROOT}/Modules/TestForANSIStreamHeaders.cmake) +INCLUDE(${CMAKE_ROOT}/Modules/CheckIncludeFileCXX.cmake) +INCLUDE(${CMAKE_ROOT}/Modules/TestForSTDNamespace.cmake) +INCLUDE(${CMAKE_ROOT}/Modules/TestForANSIForScope.cmake) +CHECK_INCLUDE_FILE_CXX("sstream" CMAKE_HAS_ANSI_STRING_STREAM) +IF(NOT CMAKE_HAS_ANSI_STRING_STREAM) + SET( CMAKE_NO_ANSI_STRING_STREAM 1 CACHE INTERNAL + "Does the compiler support sstream or stringstream.") +ENDIF(NOT CMAKE_HAS_ANSI_STRING_STREAM) diff --git a/Modules/CMakeCCompiler.cmake.in b/Modules/CMakeCCompiler.cmake.in index 86bcd0e6b..ffc0b0f22 100644 --- a/Modules/CMakeCCompiler.cmake.in +++ b/Modules/CMakeCCompiler.cmake.in @@ -2,3 +2,4 @@ SET(CMAKE_C_COMPILER "@CMAKE_C_COMPILER@") SET(CMAKE_AR "@CMAKE_AR@") SET(CMAKE_RANLIB "@CMAKE_RANLIB@") SET(CMAKE_COMPILER_IS_GNUGCC @CMAKE_COMPILER_IS_GNUGCC@) + diff --git a/Modules/CMakeCXXCompiler.cmake.in b/Modules/CMakeCXXCompiler.cmake.in index e0a9bfcdf..c86408ba0 100644 --- a/Modules/CMakeCXXCompiler.cmake.in +++ b/Modules/CMakeCXXCompiler.cmake.in @@ -1,2 +1,2 @@ SET(CMAKE_CXX_COMPILER "@CMAKE_CXX_COMPILER@") -SET(CMAKE_COMPILER_IS_GNUGXX @CMAKE_COMPILER_IS_GNUGXX@) +SET(CMAKE_COMPILER_IS_GNUCXX @CMAKE_COMPILER_IS_GNUCXX@) diff --git a/Modules/CMakeDefaultMakeRuleVariables.cmake b/Modules/CMakeDefaultMakeRuleVariables.cmake index 811ca01ff..666c81d22 100644 --- a/Modules/CMakeDefaultMakeRuleVariables.cmake +++ b/Modules/CMakeDefaultMakeRuleVariables.cmake @@ -16,22 +16,22 @@ # variables supplied by the generator at use time # +# the target without the suffix # # # +# # CXX compiler information # -# -# +# # # # C compiler information # -# -# -# +# +# # # Static library tools @@ -42,7 +42,7 @@ # create a shared C++ library IF(NOT CMAKE_CXX_CREATE_SHARED_LIBRARY) SET(CMAKE_CXX_CREATE_SHARED_LIBRARY - " -o ") + " -o ") ENDIF(NOT CMAKE_CXX_CREATE_SHARED_LIBRARY) # create a c++ shared module copy the shared library rule by default @@ -53,7 +53,7 @@ ENDIF(NOT CMAKE_CXX_CREATE_SHARED_MODULE) # create a C shared library IF(NOT CMAKE_C_CREATE_SHARED_LIBRARY) SET(CMAKE_C_CREATE_SHARED_LIBRARY - " -o ") + " -o ") ENDIF(NOT CMAKE_C_CREATE_SHARED_LIBRARY) # create a C shared module just copy the shared library rule @@ -78,23 +78,23 @@ ENDIF(NOT CMAKE_C_CREATE_STATIC_LIBRARY) # compile a C++ file into an object file IF(NOT CMAKE_CXX_COMPILE_OBJECT) SET(CMAKE_CXX_COMPILE_OBJECT - " -o -c ") + " -o -c ") ENDIF(NOT CMAKE_CXX_COMPILE_OBJECT) # compile a C file into an object file IF(NOT CMAKE_C_COMPILE_OBJECT) SET(CMAKE_C_COMPILE_OBJECT - " -o -c ") + " -o -c ") ENDIF(NOT CMAKE_C_COMPILE_OBJECT) IF(NOT CMAKE_C_LINK_EXECUTABLE) SET(CMAKE_C_LINK_EXECUTABLE - " -o ") + " -o ") ENDIF(NOT CMAKE_C_LINK_EXECUTABLE) IF(NOT CMAKE_CXX_LINK_EXECUTABLE) SET(CMAKE_CXX_LINK_EXECUTABLE - " -o ") + " -o ") ENDIF(NOT CMAKE_CXX_LINK_EXECUTABLE) diff --git a/Modules/CMakeDetermineCCompiler.cmake b/Modules/CMakeDetermineCCompiler.cmake index 032aa49ea..1432fff7f 100644 --- a/Modules/CMakeDetermineCCompiler.cmake +++ b/Modules/CMakeDetermineCCompiler.cmake @@ -1,16 +1,22 @@ # determine the compiler to use for C programs # NOTE, a generator may set CMAKE_C_COMPILER before # loading this file to force a compiler. +# use environment variable CCC first if defined by user, next use +# the cmake variable CMAKE_GENERATOR_CC which can be defined by a generator +# as a default compiler -FIND_PROGRAM(CMAKE_C_COMPILER_FULLPATH NAMES $ENV{CC} gcc cc cl bcc ) +FIND_PROGRAM(CMAKE_C_COMPILER_FULLPATH NAMES $ENV{CC} ${CMAKE_GENERATOR_CC} gcc cc cl bcc ) GET_FILENAME_COMPONENT(CMAKE_C_COMPILER ${CMAKE_C_COMPILER_FULLPATH} NAME_WE) +# set this to notfound right after so that it is searched for each time this +# file is included +SET(CMAKE_C_COMPILER_FULLPATH NOTFOUND CACHE INTERNAL "full path to c compiler" FORCE) FIND_PROGRAM(CMAKE_AR NAMES ar PATHS /bin /usr/bin /usr/local/bin) FIND_PROGRAM(CMAKE_RANLIB NAMES ranlib PATHS /bin /usr/bin /usr/local/bin) IF(NOT CMAKE_RANLIB) - SET(RANLIB :) + SET(CMAKE_RANLIB : CACHE INTERNAL "noop for ranlib") ENDIF(NOT CMAKE_RANLIB) - +MARK_AS_ADVANCED(CMAKE_RANLIB) # test to see if the c compiler is gnu EXEC_PROGRAM(${CMAKE_C_COMPILER} ARGS -E ${CMAKE_ROOT}/Modules/CMakeTestGNU.c OUTPUT_VARIABLE CMAKE_COMPILER_OUTPUT RETURN_VALUE CMAKE_COMPILER_RETURN) IF(NOT CMAKE_COMPILER_RETURN) @@ -19,6 +25,8 @@ IF(NOT CMAKE_COMPILER_RETURN) ENDIF(${CMAKE_COMPILER_OUTPUT} MATCHES ".*THIS_IS_GNU.*" ) ENDIF(NOT CMAKE_COMPILER_RETURN) + # configure variables set in this file for fast reload later on CONFIGURE_FILE(${CMAKE_ROOT}/Modules/CMakeCCompiler.cmake.in - ${PROJECT_BINARY_DIR}/CMakeCCompiler.cmake) + ${PROJECT_BINARY_DIR}/CMakeCCompiler.cmake IMMEDIATE) +MARK_AS_ADVANCED(CMAKE_AR CMAKE_C_COMPILER_FULLPATH) diff --git a/Modules/CMakeDetermineCXXCompiler.cmake b/Modules/CMakeDetermineCXXCompiler.cmake index 373d866ae..cd03d35c0 100644 --- a/Modules/CMakeDetermineCXXCompiler.cmake +++ b/Modules/CMakeDetermineCXXCompiler.cmake @@ -1,18 +1,27 @@ # determine the compiler to use for C++ programs # NOTE, a generator may set CMAKE_CXX_COMPILER before # loading this file to force a compiler. +# use environment variable CXX first if defined by user, next use +# the cmake variable CMAKE_GENERATOR_CXX which can be defined by a generator +# as a default compiler -FIND_PROGRAM(CMAKE_CXX_COMPILER_FULLPATH NAMES $ENV{CXX} c++ g++ CC aCC cl bcc ) +FIND_PROGRAM(CMAKE_CXX_COMPILER_FULLPATH NAMES $ENV{CXX} ${CMAKE_GENERATOR_CXX} c++ g++ CC aCC cl bcc ) GET_FILENAME_COMPONENT(CMAKE_CXX_COMPILER ${CMAKE_CXX_COMPILER_FULLPATH} NAME_WE) +# set this to notfound right after so that it is searched for each time this +# file is included +SET(CMAKE_CXX_COMPILER_FULLPATH NOTFOUND CACHE INTERNAL "full path to cxx compiler" FORCE) + + # test to see if the cxx compiler is gnu EXEC_PROGRAM(${CMAKE_CXX_COMPILER} ARGS -E ${CMAKE_ROOT}/Modules/CMakeTestGNU.c OUTPUT_VARIABLE CMAKE_COMPILER_OUTPUT RETURN_VALUE CMAKE_COMPILER_RETURN) IF(NOT CMAKE_COMPILER_RETURN) IF(${CMAKE_COMPILER_OUTPUT} MATCHES ".*THIS_IS_GNU.*" ) - SET(CMAKE_COMPILER_IS_GNUGXX 1) + SET(CMAKE_COMPILER_IS_GNUCXX 1) ENDIF(${CMAKE_COMPILER_OUTPUT} MATCHES ".*THIS_IS_GNU.*" ) ENDIF(NOT CMAKE_COMPILER_RETURN) # configure all variables set in this file CONFIGURE_FILE(${CMAKE_ROOT}/Modules/CMakeCXXCompiler.cmake.in - ${PROJECT_BINARY_DIR}/CMakeCXXCompiler.cmake) + ${PROJECT_BINARY_DIR}/CMakeCXXCompiler.cmake IMMEDIATE) +MARK_AS_ADVANCED(CMAKE_CXX_COMPILER_FULLPATH) diff --git a/Modules/CMakeDetermineSystem.cmake b/Modules/CMakeDetermineSystem.cmake index addbe4702..79ff941c1 100644 --- a/Modules/CMakeDetermineSystem.cmake +++ b/Modules/CMakeDetermineSystem.cmake @@ -60,6 +60,8 @@ IF(CMAKE_SYSTEM_VERSION) SET(CMAKE_SYSTEM ${CMAKE_SYSTEM}-${CMAKE_SYSTEM_VERSION}) ENDIF(CMAKE_SYSTEM_VERSION) + # configure variables set in this file for fast reload CONFIGURE_FILE(${CMAKE_ROOT}/Modules/CMakeSystem.cmake.in - ${PROJECT_BINARY_DIR}/CMakeSystem.cmake) + ${PROJECT_BINARY_DIR}/CMakeSystem.cmake IMMEDIATE) + diff --git a/Modules/CMakePrintSystemInformation.cmake b/Modules/CMakePrintSystemInformation.cmake index f31a01cde..14d5e1ca5 100644 --- a/Modules/CMakePrintSystemInformation.cmake +++ b/Modules/CMakePrintSystemInformation.cmake @@ -8,12 +8,13 @@ MESSAGE("CMAKE_C_COMPILER is ${CMAKE_C_COMPILER}") MESSAGE("CMAKE_CXX_COMPILER is ${CMAKE_CXX_COMPILER}") -MESSAGE("CMAKE_SHARED_LIBRARY_CREATE_FLAGS is ${CMAKE_SHARED_LIBRARY_CREATE_FLAGS}") +MESSAGE("CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS is ${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS}") +MESSAGE("CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS is ${CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS}") MESSAGE("CMAKE_DL_LIBS is ${CMAKE_DL_LIBS}") MESSAGE("CMAKE_SHARED_LIBRARY_PREFIX is ${CMAKE_SHARED_LIBRARY_PREFIX}") MESSAGE("CMAKE_SHARED_LIBRARY_SUFFIX is ${CMAKE_SHARED_LIBRARY_SUFFIX}") MESSAGE("CMAKE_COMPILER_IS_GNUGCC = ${CMAKE_COMPILER_IS_GNUGCC}") -MESSAGE("CMAKE_COMPILER_IS_GNUGXX = ${CMAKE_COMPILER_IS_GNUGXX}") +MESSAGE("CMAKE_COMPILER_IS_GNUCXX = ${CMAKE_COMPILER_IS_GNUCXX}") MESSAGE("CMAKE_CXX_CREATE_SHARED_LIBRARY is ${CMAKE_CXX_CREATE_SHARED_LIBRARY}") MESSAGE("CMAKE_CXX_CREATE_SHARED_MODULE is ${CMAKE_CXX_CREATE_SHARED_MODULE}") diff --git a/Modules/CMakeSystem.cmake.in b/Modules/CMakeSystem.cmake.in index 80b6e6b0a..f1d4ff197 100644 --- a/Modules/CMakeSystem.cmake.in +++ b/Modules/CMakeSystem.cmake.in @@ -1,3 +1,4 @@ SET(CMAKE_SYSTEM "@CMAKE_SYSTEM@") SET(CMAKE_SYSTEM_NAME "@CMAKE_SYSTEM_NAME@") SET(CMAKE_SYSTEM_VERSION "@CMAKE_SYSTEM_VERSION@") + diff --git a/Modules/CMakeSystemSpecificInformation.cmake b/Modules/CMakeSystemSpecificInformation.cmake index 101af5463..4d76f89d1 100644 --- a/Modules/CMakeSystemSpecificInformation.cmake +++ b/Modules/CMakeSystemSpecificInformation.cmake @@ -11,29 +11,34 @@ # 1. set default values that will work for most system + +# suffix that needs to be added onto a library to link it .lib on windows +# not used on most unix systems +SET(CMAKE_LINK_LIBRARY_SUFFIX "") + SET(CMAKE_STATIC_LIBRARY_PREFIX "lib") SET(CMAKE_STATIC_LIBRARY_SUFFIX ".a") -SET(CMAKE_SHARED_LIBRARY_C_FLAGS "") # -pic -SET(CMAKE_SHARED_LIBRARY_CXX_FLAGS "") # -pic -SET(CMAKE_SHARED_LIBRARY_CREATE_FLAGS "") # -shared SET(CMAKE_SHARED_LIBRARY_PREFIX "lib") # lib SET(CMAKE_SHARED_LIBRARY_SUFFIX ".so") # .so +SET(CMAKE_DL_LIBS "-ldl") +SET(CMAKE_SHARED_LIBRARY_C_FLAGS "") # -pic +SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared") # -shared SET(CMAKE_SHARED_LIBRARY_LINK_FLAGS "") # +s, flag for exe link to use shared lib SET(CMAKE_SHARED_LIBRARY_RUNTIME_FLAG "") # -rpath SET(CMAKE_SHARED_LIBRARY_RUNTIME_FLAG_SEP "") # : or empty SET(CMAKE_LIBRARY_PATH_FLAG "-L") SET(CMAKE_LINK_LIBRARY_FLAG "-l") -IF(CMAKE_COMPILER_IS_GNUGXX) +IF(CMAKE_COMPILER_IS_GNUCXX) SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-fPIC") # -pic SET(CMAKE_SHARED_LIBRARY_CXX_FLAGS "-fPIC") # -pic -ENDIF(CMAKE_COMPILER_IS_GNUGXX) +ENDIF(CMAKE_COMPILER_IS_GNUCXX) SET (CMAKE_SKIP_RPATH "NO" CACHE BOOL "If set, runtime paths are not added when using shared libraries.") - +MARK_AS_ADVANCED(CMAKE_SKIP_RPATH) # 2. now include SystemName.cmake file to set the system specific information -SET(CMAKE_SYSTEM_INFO_FILE ${CMAKE_ROOT}/Modules/${CMAKE_SYSTEM_NAME}.cmake) +SET(CMAKE_SYSTEM_INFO_FILE ${CMAKE_ROOT}/Modules/Platform/${CMAKE_SYSTEM_NAME}.cmake) IF(EXISTS ${CMAKE_SYSTEM_INFO_FILE}) INCLUDE(${CMAKE_SYSTEM_INFO_FILE}) ELSE(EXISTS ${CMAKE_SYSTEM_INFO_FILE}) @@ -50,17 +55,17 @@ IF(CMAKE_C_COMPILER) SET(CMAKE_BASE_NAME gcc) ENDIF(CMAKE_COMPILER_IS_GNUGCC) SET(CMAKE_SYSTEM_AND_C_COMPILER_INFO_FILE - ${CMAKE_ROOT}/Modules/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME}.cmake) + ${CMAKE_ROOT}/Modules/Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME}.cmake) INCLUDE(${CMAKE_SYSTEM_AND_C_COMPILER_INFO_FILE} OPTIONAL) ENDIF(CMAKE_C_COMPILER) IF(CMAKE_CXX_COMPILER) GET_FILENAME_COMPONENT(CMAKE_BASE_NAME ${CMAKE_CXX_COMPILER} NAME_WE) # since the gnu compiler has several names force gcc - IF(CMAKE_COMPILER_IS_GNUGXX) + IF(CMAKE_COMPILER_IS_GNUCXX) SET(CMAKE_BASE_NAME g++) - ENDIF(CMAKE_COMPILER_IS_GNUGXX) + ENDIF(CMAKE_COMPILER_IS_GNUCXX) SET(CMAKE_SYSTEM_AND_CXX_COMPILER_INFO_FILE - ${CMAKE_ROOT}/Modules/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME}.cmake) + ${CMAKE_ROOT}/Modules/Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME}.cmake) INCLUDE(${CMAKE_SYSTEM_AND_CXX_COMPILER_INFO_FILE} OPTIONAL) ENDIF(CMAKE_CXX_COMPILER) @@ -71,7 +76,7 @@ ENDIF(CMAKE_CXX_COMPILER) IF(NOT CMAKE_MODULE_EXISTS) SET(CMAKE_SHARED_MODULE_C_FLAGS ${CMAKE_SHARED_LIBRARY_C_FLAGS) SET(CMAKE_SHARED_MODULE_CXX_FLAGS ${CMAKE_SHARED_LIBRARY_CXX_FLAGS}) - SET(CMAKE_SHARED_MODULE_CREATE_FLAGS ${CMAKE_SHARED_LIBRARY_CREATE_FLAGS}) + SET(CMAKE_SHARED_MODULE_CREATE_C_FLAGS ${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS}) SET(CMAKE_SHARED_MODULE_PREFIX ${CMAKE_SHARED_LIBRARY_PREFIX}) SET(CMAKE_SHARED_MODULE_SUFFIX ${CMAKE_SHARED_LIBRARY_SUFFIX}) SET(CMAKE_SHARED_MODULE_LINK_FLAGS ${CMAKE_SHARED_LIBRARY_LINK_FLAGS}) @@ -79,6 +84,28 @@ IF(NOT CMAKE_MODULE_EXISTS) SET(CMAKE_SHARED_MODULE_RUNTIME_FLAG_SEP ${CMAKE_SHARED_MODULE_RUNTIME_FLAG_SEP}) ENDIF(NOT CMAKE_MODULE_EXISTS) + +IF(NOT CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS) + SET(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS ${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS}) +ENDIF(NOT CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS) + +IF(NOT CMAKE_SHARED_LIBRARY_CXX_FLAGS) + SET(CMAKE_SHARED_LIBRARY_CXX_FLAGS ${CMAKE_SHARED_LIBRARY_C_FLAGS}) +ENDIF(NOT CMAKE_SHARED_LIBRARY_CXX_FLAGS) + +IF(NOT CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS) + SET(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS ${CMAKE_SHARED_LIBRARY_LINK_FLAGS}) +ENDIF(NOT CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS) + +IF(NOT CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG) + SET(CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG ${CMAKE_SHARED_LIBRARY_RUNTIME_FLAG}) +ENDIF(NOT CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG) + +IF(NOT CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG_SEP) + SET(CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG_SEP ${CMAKE_SHARED_LIBRARY_RUNTIME_FLAG_SEP}) +ENDIF(NOT CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG_SEP) + + # include default rules that work for most unix like systems and compilers # this file will not set anything if it is already set INCLUDE(${CMAKE_ROOT}/Modules/CMakeDefaultMakeRuleVariables.cmake) @@ -86,3 +113,19 @@ INCLUDE(${CMAKE_ROOT}/Modules/CMakeDefaultMakeRuleVariables.cmake) IF(CMAKE_USER_MAKE_RULES_OVERRIDE) INCLUDE(${CMAKE_USER_MAKE_RULES_OVERRIDE}) ENDIF(CMAKE_USER_MAKE_RULES_OVERRIDE) + +FIND_PROGRAM(CMAKE_MAKE_PROGRAM NAMES nmake gmake make ) + +SET(CMAKE_VERBOSE_MAKEFILE FALSE CACHE BOOL "If this value is on, makefiles will be generated without the .SILENT directive, and all commands will be echoed to the console during the make. This is useful for debugging only.") +# default build type is none +SET (CMAKE_BUILD_TYPE "" CACHE STRING + "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.") +MARK_AS_ADVANCED( +CMAKE_VERBOSE_MAKEFILE +CMAKE_CXX_FLAGS +CMAKE_CXX_FLAGS_RELEASE +CMAKE_CXX_FLAGS_RELWITHDEBINFO +CMAKE_CXX_FLAGS_MINSIZEREL +CMAKE_CXX_FLAGS_DEBUG +CMAKE_C_FLAGS +) diff --git a/Modules/CYGWIN.cmake b/Modules/CYGWIN.cmake deleted file mode 100644 index cad44bc0e..000000000 --- a/Modules/CYGWIN.cmake +++ /dev/null @@ -1,7 +0,0 @@ -SET(CMAKE_SHARED_LIBRARY_CREATE_FLAGS "-shared") -SET(CMAKE_DL_LIBS "-lgdi32" ) -SET(CMAKE_SHARED_LIBRARY_PREFIX "") -SET(CMAKE_SHARED_LIBRARY_SUFFIX ".dll") -# no pic for gcc on cygwin -SET(CMAKE_SHARED_LIBRARY_C_FLAGS "") -SET(CMAKE_SHARED_LIBRARY_CXX_FLAGS "") diff --git a/Modules/CheckIncludeFile.cxx.in b/Modules/CheckIncludeFile.cxx.in new file mode 100644 index 000000000..40441f15a --- /dev/null +++ b/Modules/CheckIncludeFile.cxx.in @@ -0,0 +1,6 @@ +#include <${CHECK_INCLUDE_FILE_VAR}> + +int main() +{ + return 0; +} diff --git a/Modules/CheckIncludeFileCXX.cmake b/Modules/CheckIncludeFileCXX.cmake new file mode 100644 index 000000000..7295f66a6 --- /dev/null +++ b/Modules/CheckIncludeFileCXX.cmake @@ -0,0 +1,26 @@ +# +# Check if the include file exists. +# +# CHECK_INCLUDE_FILE - macro which checks the include file exists. +# INCLUDE - name of include file +# VARIABLE - variable to return result +# + +MACRO(CHECK_INCLUDE_FILE_CXX INCLUDE VARIABLE) + SET(CHECK_INCLUDE_FILE_VAR ${INCLUDE}) + CONFIGURE_FILE(${CMAKE_ROOT}/Modules/CheckIncludeFile.cxx.in + ${PROJECT_BINARY_DIR}/CMakeTmp/CheckIncludeFile.cxx IMMEDIATE) + TRY_COMPILE(${VARIABLE} + ${PROJECT_BINARY_DIR} + ${PROJECT_BINARY_DIR}/CMakeTmp/CheckIncludeFile.cxx + OUTPUT_VARIABLE OUTPUT) + IF(${VARIABLE}) + SET(${VARIABLE} 1 CACHE INTERNAL "Have include ${INCLUDE}") + ELSE(${VARIABLE}) + SET(${VARIABLE} "" CACHE INTERNAL "Have include ${INCLUDE}") + WRITE_FILE(${PROJECT_BINARY_DIR}/CMakeError.log + "Determining if the include file ${INCLUDE} " + "exists failed with the following output:\n" + "${OUTPUT}\n") + ENDIF(${VARIABLE}) +ENDMACRO(CHECK_INCLUDE_FILE_CXX) diff --git a/Modules/Platform/AIX.cmake b/Modules/Platform/AIX.cmake new file mode 100644 index 000000000..38543f516 --- /dev/null +++ b/Modules/Platform/AIX.cmake @@ -0,0 +1,9 @@ +SET(CMAKE_SHARED_LIBRARY_PREFIX "lib") # lib +SET(CMAKE_SHARED_LIBRARY_SUFFIX "..o") # .so +SET(CMAKE_DL_LIBS "-lld") + +IF(CMAKE_COMPILER_IS_GNUCXX) + SET(CMAKE_SHARED_LIBRARY_SUFFIX ".so") # .so + SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared -Wl,-G") # -shared + SET(CMAKE_SHARED_LIBRARY_LINK_FLAGS "-Wl,-brtl") # +s, flag for exe link to use shared lib +ENDIF(CMAKE_COMPILER_IS_GNUCXX) diff --git a/Modules/Platform/BSDOS.cmake b/Modules/Platform/BSDOS.cmake new file mode 100644 index 000000000..e69de29bb diff --git a/Modules/Platform/CYGWIN.cmake b/Modules/Platform/CYGWIN.cmake new file mode 100644 index 000000000..6cb3e1826 --- /dev/null +++ b/Modules/Platform/CYGWIN.cmake @@ -0,0 +1,11 @@ +SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared") +SET(CMAKE_DL_LIBS "-lgdi32" ) +SET(CMAKE_SHARED_LIBRARY_PREFIX "lib") +SET(CMAKE_SHARED_LIBRARY_SUFFIX ".dll") +# no pic for gcc on cygwin +SET(CMAKE_SHARED_LIBRARY_C_FLAGS "") +SET(CMAKE_SHARED_LIBRARY_CXX_FLAGS "") +INCLUDE(${CMAKE_ROOT}/Modules/Platform/gcc.cmake) +FIND_PROGRAM(CMAKE_MAKE_PROGRAM NAMES gmake make ) +SET(CMAKE_BUILD_TOOL ${CMAKE_MAKE_PROGRAM} CACHE INTERNAL + "What is the target build tool cmake is generating for.") diff --git a/Modules/Platform/Darwin.cmake b/Modules/Platform/Darwin.cmake new file mode 100644 index 000000000..5a6068c17 --- /dev/null +++ b/Modules/Platform/Darwin.cmake @@ -0,0 +1,18 @@ +SET(CMAKE_SHARED_LIBRARY_PREFIX "lib") +SET(CMAKE_SHARED_LIBRARY_SUFFIX ".dylib") +SET(CMAKE_SHARED_MODULE_SUFFIX ".so") +SET(CMAKE_DL_LIBS "") +SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-dynamiclib") +SET(CMAKE_SHARED_MODULE_CREATE_C_FLAGS "-bundle -flat_namespace -undefined suppress") + +SET(CMAKE_CXX_CREATE_SHARED_LIBRARY + " -o ") + +SET(CMAKE_C_CREATE_SHARED_LIBRARY + " -o ") + +SET(CMAKE_CXX_CREATE_SHARED_MODULE + " -o ") + +SET(CMAKE_C_CREATE_SHARED_MODULE + " -o ") diff --git a/Modules/Platform/FreeBSD.cmake b/Modules/Platform/FreeBSD.cmake new file mode 100644 index 000000000..e9c9ab224 --- /dev/null +++ b/Modules/Platform/FreeBSD.cmake @@ -0,0 +1,8 @@ +IF(EXISTS /usr/include/dlfcn.h) + SET(CMAKE_DL_LIBS "") + SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-fPIC") # -pic + SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared") # -shared + SET(CMAKE_SHARED_LIBRARY_LINK_FLAGS "") # +s, flag for exe link to use shared lib + SET(CMAKE_SHARED_LIBRARY_RUNTIME_FLAG "-Wl,-rpath,") # -rpath + SET(CMAKE_SHARED_LIBRARY_RUNTIME_FLAG_SEP ":") # : or empty +ENDIF(EXISTS /usr/include/dlfcn.h) diff --git a/Modules/Platform/HP-UX.cmake b/Modules/Platform/HP-UX.cmake new file mode 100644 index 000000000..0f123b0e0 --- /dev/null +++ b/Modules/Platform/HP-UX.cmake @@ -0,0 +1,57 @@ +SET(CMAKE_SHARED_LIBRARY_SUFFIX ".sl") # .so +SET(CMAKE_DL_LIBS "-ldld") + +SET(CMAKE_SHARED_LIBRARY_RUNTIME_FLAG_SEP ":") # : or empty + +# C compiler +IF(CMAKE_COMPILER_IS_GNUCC) + # gnu gcc + SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-fPIC") # -pic + SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared -Wl,-E -Wl,-b") # -shared + SET(CMAKE_SHARED_LIBRARY_LINK_FLAGS "-Wl,+s") # +s, flag for exe link to use shared lib + SET(CMAKE_SHARED_LIBRARY_RUNTIME_FLAG "-Wl,+b") # -rpath + SET(CMAKE_SHARED_LIBRARY_RUNTIME_FLAG_SEP ":") # : or empty + SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-fPIC") # -pic +ELSE(CMAKE_COMPILER_IS_GNUCC) + # hp cc + SET(CMAKE_ANSI_CFLAGS "-Ae -Aa") + # use ld directly to create shared libraries for hp cc + SET(CMAKE_C_CREATE_SHARED_LIBRARY + "ld -o ") + SET(CMAKE_SHARED_LIBRARY_C_FLAGS "+Z") # -pic + SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-E -b -L/usr/lib") # -shared + SET(CMAKE_SHARED_LIBRARY_LINK_FLAGS "+s") # +s, flag for exe link to use shared lib + SET(CMAKE_SHARED_LIBRARY_RUNTIME_FLAG "+b") # -rpath +ENDIF(CMAKE_COMPILER_IS_GNUCC) + +# CXX compiler +IF(CMAKE_COMPILER_IS_GNUCXX) + INCLUDE(${CMAKE_ROOT}/Modules/Platform/gcc.cmake) + # for gnu C++ + SET(CMAKE_SHARED_LIBRARY_CXX_FLAGS "-fPIC") # -pic + SET(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "-shared -Wl,-E -Wl,-b") # -shared + SET(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "-Wl,+s") # +s, flag for exe link to use shared lib + SET(CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG "-Wl,+b") # -rpath + SET(CMAKE_SHARED_LIBRARY_CXX_FLAGS "-fPIC") # -pic +ELSE(CMAKE_COMPILER_IS_GNUCXX) + # for hp aCC + SET(CMAKE_SHARED_LIBRARY_CXX_FLAGS "+Z") # -pic + SET(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "+Z -Wl,-E -b -L/usr/lib") # -shared + SET(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "-Wl,+s") # +s, flag for exe link to use shared lib + SET(CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG "-Wl,+b") # -rpath + SET(CMAKE_SHARED_LIBRARY_CXX_FLAGS "-fPIC") # -pic + + SET (CMAKE_CXX_FLAGS "" CACHE STRING + "Flags used by the compiler during all build types.") + SET (CMAKE_CXX_FLAGS_DEBUG "-g" CACHE STRING + "Flags used by the compiler during debug builds.") + SET (CMAKE_CXX_FLAGS_MINSIZEREL "-O3" CACHE STRING + "Flags used by the compiler during release minsize builds.") + SET (CMAKE_CXX_FLAGS_RELEASE "-O2" CACHE STRING + "Flags used by the compiler during release builds (/MD /Ob1 /Oi /Ot /Oy /Gs will produce slightly less optimized but smaller files).") + SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO "-g" CACHE STRING + "Flags used by the compiler during Release with Debug Info builds.") + SET (CMAKE_C_FLAGS "" CACHE STRING + "Flags for C compiler.") + +ENDIF(CMAKE_COMPILER_IS_GNUCXX) diff --git a/Modules/Platform/IRIX.cmake b/Modules/Platform/IRIX.cmake new file mode 100644 index 000000000..62c374c30 --- /dev/null +++ b/Modules/Platform/IRIX.cmake @@ -0,0 +1,29 @@ +SET(CMAKE_DL_LIBS "") +SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared -rdata_shared") +SET(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "-shared -rdata_shared") +SET(CMAKE_SHARED_LIBRARY_RUNTIME_FLAG "-Wl,-rpath,") # -rpath +SET(CMAKE_SHARED_LIBRARY_RUNTIME_FLAG_SEP "") # : or empty +IF(NOT CMAKE_COMPILER_IS_GNUCXX) + SET(CMAKE_CXX_CREATE_STATIC_LIBRARY + " -ar -o ") + SET (CMAKE_CXX_FLAGS "" CACHE STRING + "Flags used by the compiler during all build types.") + + SET (CMAKE_CXX_FLAGS_DEBUG "-g" CACHE STRING + "Flags used by the compiler during debug builds.") + + SET (CMAKE_CXX_FLAGS_MINSIZEREL "-O3" CACHE STRING + "Flags used by the compiler during release minsize builds.") + + SET (CMAKE_CXX_FLAGS_RELEASE "-O2" CACHE STRING + "Flags used by the compiler during release builds (/MD /Ob1 /Oi /Ot /Oy /Gs will produce slightly less optimized but smaller files).") + + SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2" CACHE STRING + "Flags used by the compiler during Release with Debug Info builds.") + + SET (CMAKE_C_FLAGS "" CACHE STRING + "Flags for C compiler.") +ELSE(NOT CMAKE_COMPILER_IS_GNUCXX) + INCLUDE(${CMAKE_ROOT}/Modules/Platform/gcc.cmake) +ENDIF(NOT CMAKE_COMPILER_IS_GNUCXX) + diff --git a/Modules/Platform/IRIX64.cmake b/Modules/Platform/IRIX64.cmake new file mode 100644 index 000000000..5ff106584 --- /dev/null +++ b/Modules/Platform/IRIX64.cmake @@ -0,0 +1,31 @@ +SET(CMAKE_DL_LIBS "") +SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared -rdata_shared") +SET(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "-shared -rdata_shared") +SET(CMAKE_SHARED_LIBRARY_RUNTIME_FLAG "-Wl,-rpath,") # -rpath +SET(CMAKE_SHARED_LIBRARY_RUNTIME_FLAG_SEP "") # : or empty +IF(NOT CMAKE_COMPILER_IS_GNUCXX) + SET(CMAKE_CXX_CREATE_STATIC_LIBRARY + " -ar -o ") + SET(CMAKE_ANSI_CXXFLAGS -LANG:std) + SET (CMAKE_CXX_FLAGS "" CACHE STRING + "Flags used by the compiler during all build types.") + + SET (CMAKE_CXX_FLAGS_DEBUG "-g" CACHE STRING + "Flags used by the compiler during debug builds.") + + SET (CMAKE_CXX_FLAGS_MINSIZEREL "-O3" CACHE STRING + "Flags used by the compiler during release minsize builds.") + + SET (CMAKE_CXX_FLAGS_RELEASE "-O2" CACHE STRING + "Flags used by the compiler during release builds (/MD /Ob1 /Oi /Ot /Oy /Gs will produce slightly less optimized but smaller files).") + + SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2" CACHE STRING + "Flags used by the compiler during Release with Debug Info builds.") + + + SET (CMAKE_C_FLAGS "" CACHE STRING + "Flags for C compiler.") +ELSE(NOT CMAKE_COMPILER_IS_GNUCXX) + INCLUDE(${CMAKE_ROOT}/Modules/Platform/gcc.cmake) +ENDIF(NOT CMAKE_COMPILER_IS_GNUCXX) + diff --git a/Modules/Platform/Linux.cmake b/Modules/Platform/Linux.cmake new file mode 100644 index 000000000..b3091b71b --- /dev/null +++ b/Modules/Platform/Linux.cmake @@ -0,0 +1,7 @@ +SET(CMAKE_DL_LIBS "-ldl") +SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-fPIC") +SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared") +SET(CMAKE_SHARED_LIBRARY_LINK_FLAGS "-rdynamic") +SET(CMAKE_SHARED_LIBRARY_RUNTIME_FLAG "-Wl,-rpath,") +SET(CMAKE_SHARED_LIBRARY_RUNTIME_FLAG_SEP ":") + diff --git a/Modules/Platform/MP-RAS.cmake b/Modules/Platform/MP-RAS.cmake new file mode 100644 index 000000000..5a644dcda --- /dev/null +++ b/Modules/Platform/MP-RAS.cmake @@ -0,0 +1,9 @@ +IF(CMAKE_SYSTEM MATCHES "MP-RAS-02*.") + SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-K PIC") +ELSE(CMAKE_SYSTEM MATCHES "MP-RAS-02*.") + SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-K PIC") + SET(CMAKE_SHARED_LIBRARY_LINK_FLAGS "-Wl,-Bexport") +ENDIF(CMAKE_SYSTEM MATCHES "MP-RAS-02*.") + + + diff --git a/Modules/Platform/NetBSD.cmake b/Modules/Platform/NetBSD.cmake new file mode 100644 index 000000000..e9c9ab224 --- /dev/null +++ b/Modules/Platform/NetBSD.cmake @@ -0,0 +1,8 @@ +IF(EXISTS /usr/include/dlfcn.h) + SET(CMAKE_DL_LIBS "") + SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-fPIC") # -pic + SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared") # -shared + SET(CMAKE_SHARED_LIBRARY_LINK_FLAGS "") # +s, flag for exe link to use shared lib + SET(CMAKE_SHARED_LIBRARY_RUNTIME_FLAG "-Wl,-rpath,") # -rpath + SET(CMAKE_SHARED_LIBRARY_RUNTIME_FLAG_SEP ":") # : or empty +ENDIF(EXISTS /usr/include/dlfcn.h) diff --git a/Modules/Platform/OSF1.cmake b/Modules/Platform/OSF1.cmake new file mode 100644 index 000000000..0fb534864 --- /dev/null +++ b/Modules/Platform/OSF1.cmake @@ -0,0 +1,26 @@ +SET(CMAKE_DL_LIBS "") + +IF(CMAKE_SYSTEM MATCHES "OSF1-1.[012]") +ENDIF(CMAKE_SYSTEM MATCHES "OSF1-1.[012]") +IF(CMAKE_SYSTEM MATCHES "OSF1-1.*") + # OSF/1 1.3 from OSF using ELF, and derivatives, including AD2 + SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-fpic") # -pic + SET(CMAKE_SHARED_LIBRARY_CXX_FLAGS "-fpic") # -pic +ENDIF(CMAKE_SYSTEM MATCHES "OSF1-1.*") + + + +IF(CMAKE_SYSTEM MATCHES "OSF1-V.*") + SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared -Wl,-expect_unresolved,\\*") # -shared + SET(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "-shared -Wl,-expect_unresolved,\\*") # -shared + IF(CMAKE_COMPILER_IS_GNUCXX) + SET(CMAKE_SHARED_LIBRARY_RUNTIME_FLAG "-Wl,-rpath,") + ELSE(CMAKE_COMPILER_IS_GNUCXX) + SET(CMAKE_SHARED_LIBRARY_RUNTIME_FLAG "-rpath,") + ENDIF(CMAKE_COMPILER_IS_GNUCXX) + SET(CMAKE_SHARED_LIBRARY_RUNTIME_FLAG_SEP ":") +ENDIF(CMAKE_SYSTEM MATCHES "OSF1-V.*") + +IF(NOT CMAKE_COMPILER_IS_GNUCXX) + SET(CMAKE_ANSI_CXXFLAGS "-std strict_ansi -nopure_cname") +ENDIF(NOT CMAKE_COMPILER_IS_GNUCXX) diff --git a/Modules/Platform/OpenBSD.cmake b/Modules/Platform/OpenBSD.cmake new file mode 100644 index 000000000..e69de29bb diff --git a/Modules/Platform/RISCos.cmake b/Modules/Platform/RISCos.cmake new file mode 100644 index 000000000..1979d5e56 --- /dev/null +++ b/Modules/Platform/RISCos.cmake @@ -0,0 +1,4 @@ +SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-G 0") +SET(CMAKE_SHARED_LIBRARY_SUFFIX "..o") +SET(CMAKE_DL_LIBS "") +SET(CMAKE_SHARED_LIBRARY_LINK_FLAGS "-Wl,-D,08000000") diff --git a/Modules/Platform/SCO_SV.cmake b/Modules/Platform/SCO_SV.cmake new file mode 100644 index 000000000..89dcd56f9 --- /dev/null +++ b/Modules/Platform/SCO_SV.cmake @@ -0,0 +1,4 @@ +SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-Kpic -belf") +SET(CMAKE_SHARED_LIBRARY_CXX_FLAGS "-Kpic -belf") +SET(CMAKE_DL_LIBS "") +SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-belf -Wl,-Bexport") diff --git a/Modules/Platform/SINIX.cmake b/Modules/Platform/SINIX.cmake new file mode 100644 index 000000000..134d78b11 --- /dev/null +++ b/Modules/Platform/SINIX.cmake @@ -0,0 +1 @@ + SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-K PIC") diff --git a/Modules/Platform/SunOS.cmake b/Modules/Platform/SunOS.cmake new file mode 100644 index 000000000..94fe52804 --- /dev/null +++ b/Modules/Platform/SunOS.cmake @@ -0,0 +1,25 @@ +IF(CMAKE_SYSTEM MATCHES "SunOS-4.*") + SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-PIC") + SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared -Wl,-r -nostdlib") + SET(CMAKE_SHARED_LIBRARY_RUNTIME_FLAG "-Wl,-R,") + SET(CMAKE_SHARED_LIBRARY_RUNTIME_FLAG_SEP ":") +ENDIF(CMAKE_SYSTEM MATCHES "SunOS-4.*") + +IF(CMAKE_SYSTEM MATCHES "SunOS-5*.") + SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-KPIC") + SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-G") + SET(CMAKE_SHARED_LIBRARY_RUNTIME_FLAG "-R,") + SET(CMAKE_SHARED_LIBRARY_RUNTIME_FLAG_SEP ":") + IF(CMAKE_COMPILER_IS_GNUCXX) + SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared -nostdlib") + SET(CMAKE_SHARED_LIBRARY_RUNTIME_FLAG "-Wl,-R,") + SET(CMAKE_SHARED_LIBRARY_RUNTIME_FLAG_SEP ":") + ENDIF(CMAKE_COMPILER_IS_GNUCXX) +ENDIF(CMAKE_SYSTEM MATCHES "SunOS-5*.") + +IF(NOT CMAKE_COMPILER_IS_GNUCXX) + SET(CMAKE_CXX_CREATE_STATIC_LIBRARY + " -xar -o " + " ") +ENDIF(NOT CMAKE_COMPILER_IS_GNUCXX) + diff --git a/Modules/Platform/True64.cmake b/Modules/Platform/True64.cmake new file mode 100644 index 000000000..e69de29bb diff --git a/Modules/Platform/ULTRIX.cmake b/Modules/Platform/ULTRIX.cmake new file mode 100644 index 000000000..406472185 --- /dev/null +++ b/Modules/Platform/ULTRIX.cmake @@ -0,0 +1,4 @@ +SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-G 0") +SET(CMAKE_SHARED_LIBRARY_SUFFIX "..o") +SET(CMAKE_DL_LIBS "") +SET(CMAKE_SHARED_LIBRARY_LINK_FLAGS "-Wl,-D,08000000") diff --git a/Modules/Platform/UNIX_SV.cmake b/Modules/Platform/UNIX_SV.cmake new file mode 100644 index 000000000..62b0e5994 --- /dev/null +++ b/Modules/Platform/UNIX_SV.cmake @@ -0,0 +1,2 @@ +SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-K PIC") +SET(CMAKE_SHARED_LIBRARY_LINK_FLAGS "-Wl,-Bexport") diff --git a/Modules/Platform/UnixWare.cmake b/Modules/Platform/UnixWare.cmake new file mode 100644 index 000000000..80acb870c --- /dev/null +++ b/Modules/Platform/UnixWare.cmake @@ -0,0 +1,2 @@ +SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-K PIC") +SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-Wl,-Bexport") diff --git a/Modules/Platform/Windows-bcc32.cmake b/Modules/Platform/Windows-bcc32.cmake new file mode 100644 index 000000000..744e44c96 --- /dev/null +++ b/Modules/Platform/Windows-bcc32.cmake @@ -0,0 +1,78 @@ +SET(CMAKE_LIBRARY_PATH_FLAG "-L") +SET(CMAKE_LINK_LIBRARY_FLAG "") + +# create a shared C++ library +SET(CMAKE_CXX_CREATE_SHARED_LIBRARY + " @&&|\n-e -tWD \n|" + "implib @&&|\n-w .lib .dll\n|" +) + +SET(CMAKE_CXX_CREATE_SHARED_MODULE ${CMAKE_CXX_CREATE_SHARED_LIBRARY}) + +# create a C shared library +SET(CMAKE_C_CREATE_SHARED_LIBRARY + " @&&|\n-e -tWD \n|" + "implib @&&|\n-w .lib .dll\n|" +) + +# create a C shared module just copy the shared library rule +SET(CMAKE_C_CREATE_SHARED_MODULE ${CMAKE_C_CREATE_SHARED_LIBRARY}) + + +# create a C++ static library +SET(CMAKE_CXX_CREATE_STATIC_LIBRARY "tlib @&&|\n/p512 /a \n|") + +# create a C static library +SET(CMAKE_C_CREATE_STATIC_LIBRARY ${CMAKE_CXX_CREATE_STATIC_LIBRARY}) + +# compile a C++ file into an object file +SET(CMAKE_CXX_COMPILE_OBJECT + " @&&|\n-DWIN32 -o -c \n|") + +# compile a C file into an object file +SET(CMAKE_C_COMPILE_OBJECT + " @&&|\n-DWIN32 -o -c \n|") + + +SET(CMAKE_C_LINK_EXECUTABLE + " @&&|\n-e \n|") + + +SET(CMAKE_CXX_LINK_EXECUTABLE + " @&&|\n -e \n|") + +SET (CMAKE_BUILD_TYPE Debug CACHE STRING + "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel.") + +# extra flags for a win32 exe +SET(CMAKE_CREATE_WIN32_EXE -tW -tWM ) +# extra flags for a console app +SET(CMAKE_CREATE_CONSOLE_EXE -tWC ) + +SET (CMAKE_CXX_FLAGS "-w- -whid -waus -wpar -tWM -P" CACHE STRING + "Flags used to compile c++ files.") + +SET (CMAKE_CXX_FLAGS_DEBUG "-Od -v" CACHE STRING + "Flags used by the compiler during debug builds.") + +SET (CMAKE_CXX_FLAGS_MINSIZEREL "-O1" CACHE STRING + "Flags used by the compiler during release minsize builds.") + +SET (CMAKE_CXX_FLAGS_RELEASE "-O2" CACHE STRING + "Release flags.") + +SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO "-Od" CACHE STRING + "Flags used by the compiler during Release with Debug Info builds.") + + +SET (CMAKE_C_FLAGS "-w- -whid -waus -tWM" CACHE STRING + "Flags for C compiler.") + +SET (CMAKE_STANDARD_LIBRARIES "import32.lib" CACHE STRING + "Libraries linked by defalut with all applications.") + +FIND_PROGRAM(CMAKE_MAKE_PROGRAM NAMES make ) +SET(CMAKE_BUILD_TOOL ${CMAKE_MAKE_PROGRAM} CACHE INTERNAL + "What is the target build tool cmake is generating for.") +MARK_AS_ADVANCED(CMAKE_STANDARD_LIBRARIES CMAKE_MAKE_PROGRAM) + diff --git a/Modules/Platform/Windows-cl.cmake b/Modules/Platform/Windows-cl.cmake new file mode 100644 index 000000000..bf274fa88 --- /dev/null +++ b/Modules/Platform/Windows-cl.cmake @@ -0,0 +1,70 @@ +SET(CMAKE_LIBRARY_PATH_FLAG "-LIBPATH:") +SET(CMAKE_LINK_LIBRARY_FLAG "") + +# create a shared C++ library +SET(CMAKE_CXX_CREATE_SHARED_LIBRARY + "link @<<\n /out: /dll \n<<") + +SET(CMAKE_CXX_CREATE_SHARED_MODULE ${CMAKE_CXX_CREATE_SHARED_LIBRARY}) + +# create a C shared library +SET(CMAKE_C_CREATE_SHARED_LIBRARY ${CMAKE_CXX_CREATE_SHARED_LIBRARY}) + +# create a C shared module just copy the shared library rule +SET(CMAKE_C_CREATE_SHARED_MODULE ${CMAKE_C_CREATE_SHARED_LIBRARY}) + + +# create a C++ static library +SET(CMAKE_CXX_CREATE_STATIC_LIBRARY "lib /nologo /out: ") + +# create a C static library +SET(CMAKE_C_CREATE_STATIC_LIBRARY ${CMAKE_CXX_CREATE_STATIC_LIBRARY}) + +# compile a C++ file into an object file +SET(CMAKE_CXX_COMPILE_OBJECT + " @<<\n -DWIN32 /Fo -c \n<<") + +# compile a C file into an object file +SET(CMAKE_C_COMPILE_OBJECT + " @<<\n -DWIN32 /Fo -c \n<<") + + +SET(CMAKE_C_LINK_EXECUTABLE + " @<<\n /Fe -link \n<<") + +SET(CMAKE_COMPILE_RESOURCE "rc /fo ") + +SET(CMAKE_CXX_LINK_EXECUTABLE + " @<<\n /Fe -link \n<<") + +SET (CMAKE_BUILD_TYPE Debug CACHE STRING + "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel.") + +SET(CMAKE_CREATE_WIN32_EXE /subsystem:windows) + +SET (CMAKE_CXX_FLAGS "/nologo /W3 /Zm1000 /GX /GR" CACHE STRING + "Flags used by the compiler during all build types, /GX /GR are for exceptions and rtti in VC++, /Zm1000 increases the compiler's memory allocation to support ANSI C++/stdlib.") + +SET (CMAKE_CXX_FLAGS_DEBUG "/MDd /Zi /Od /GZ" CACHE STRING + "Flags used by the compiler during debug builds.") + +SET (CMAKE_CXX_FLAGS_MINSIZEREL "/MD /O1" CACHE STRING + "Flags used by the compiler during release minsize builds.") + +SET (CMAKE_CXX_FLAGS_RELEASE "/MD /O2" CACHE STRING + "Flags used by the compiler during release builds (/MD /Ob1 /Oi /Ot /Oy /Gs will produce slightly less optimized but smaller files).") + +SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO "/MD /Zi /O2" CACHE STRING + "Flags used by the compiler during Release with Debug Info builds.") + + +SET (CMAKE_C_FLAGS "/nologo /W3 /Zm1000" CACHE STRING + "Flags for C compiler.") + +SET (CMAKE_STANDARD_LIBRARIES "kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib" CACHE STRING + "Libraries linked by defalut with all applications.") +MARK_AS_ADVANCED(CMAKE_STANDARD_LIBRARIES) + +FIND_PROGRAM(CMAKE_MAKE_PROGRAM NAMES nmake ) +SET(CMAKE_BUILD_TOOL ${CMAKE_MAKE_PROGRAM} CACHE INTERNAL + "What is the target build tool cmake is generating for.") diff --git a/Modules/Platform/Windows.cmake b/Modules/Platform/Windows.cmake new file mode 100644 index 000000000..cf465161c --- /dev/null +++ b/Modules/Platform/Windows.cmake @@ -0,0 +1,6 @@ +SET(CMAKE_STATIC_LIBRARY_PREFIX "") +SET(CMAKE_STATIC_LIBRARY_SUFFIX ".lib") +SET(CMAKE_SHARED_LIBRARY_PREFIX "") # lib +SET(CMAKE_SHARED_LIBRARY_SUFFIX ".dll") # .so +SET(CMAKE_LINK_LIBRARY_SUFFIX ".lib") +SET(CMAKE_DL_LIBS "") diff --git a/Modules/Platform/Xenix.cmake b/Modules/Platform/Xenix.cmake new file mode 100644 index 000000000..e69de29bb diff --git a/Modules/Platform/gcc.cmake b/Modules/Platform/gcc.cmake new file mode 100644 index 000000000..55612bdf0 --- /dev/null +++ b/Modules/Platform/gcc.cmake @@ -0,0 +1,18 @@ +SET (CMAKE_CXX_FLAGS "" CACHE STRING + "Flags used by the compiler during all build types.") + +SET (CMAKE_CXX_FLAGS_DEBUG "-g" CACHE STRING + "Flags used by the compiler during debug builds.") + +SET (CMAKE_CXX_FLAGS_MINSIZEREL "-O3" CACHE STRING + "Flags used by the compiler during release minsize builds.") + +SET (CMAKE_CXX_FLAGS_RELEASE "-O2" CACHE STRING + "Flags used by the compiler during release builds (/MD /Ob1 /Oi /Ot /Oy /Gs will produce slightly less optimized but smaller files).") + +SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g" CACHE STRING + "Flags used by the compiler during Release with Debug Info builds.") + + +SET (CMAKE_C_FLAGS "" CACHE STRING + "Flags for C compiler.") diff --git a/Modules/TestForANSIForScope.cmake b/Modules/TestForANSIForScope.cmake new file mode 100644 index 000000000..c6434b4e4 --- /dev/null +++ b/Modules/TestForANSIForScope.cmake @@ -0,0 +1,19 @@ +# +# check if the compiler supports std:: on stl classes +# +# CMAKE_NO_STD_NAMESPACE - defined accoreding to the results +# + +TRY_COMPILE(CMAKE_ANSI_FOR_SCOPE ${PROJECT_BINARY_DIR} + ${CMAKE_ROOT}/Modules/TestForAnsiForScope.cxx) +IF (CMAKE_ANSI_FOR_SCOPE) + SET (CMAKE_NO_ANSI_FOR_SCOPE 0 CACHE INTERNAL + "Does the compiler support ansi for scope.") +ELSE (CMAKE_ANSI_FOR_SCOPE) + SET (CMAKE_NO_ANSI_FOR_SCOPE 1 CACHE INTERNAL + "Does the compiler support ansi for scope.") +ENDIF (CMAKE_ANSI_FOR_SCOPE) + + + + diff --git a/Modules/TestForAnsiForScope.cxx b/Modules/TestForAnsiForScope.cxx new file mode 100644 index 000000000..00dd9c958 --- /dev/null +++ b/Modules/TestForAnsiForScope.cxx @@ -0,0 +1,7 @@ +int main(int, char*[]) +{ + int i; + for(int i=0; i < 1; ++i) ; + return 0; +} + diff --git a/Modules/TestForSTDNamespace.cmake b/Modules/TestForSTDNamespace.cmake new file mode 100644 index 000000000..304d1c3b0 --- /dev/null +++ b/Modules/TestForSTDNamespace.cmake @@ -0,0 +1,18 @@ +# +# check if the compiler supports std:: on stl classes +# +# CMAKE_NO_STD_NAMESPACE - defined accoreding to the results +# + +TRY_COMPILE(CMAKE_STD_NAMESPACE ${PROJECT_BINARY_DIR} + ${CMAKE_ROOT}/Modules/TestForSTDNamespace.cxx) +IF (CMAKE_STD_NAMESPACE) + SET (CMAKE_NO_STD_NAMESPACE 0 CACHE INTERNAL + "Does the compiler support std::.") +ELSE (CMAKE_STD_NAMESPACE) + SET (CMAKE_NO_STD_NAMESPACE 1 CACHE INTERNAL + "Does the compiler support std::.") +ENDIF (CMAKE_STD_NAMESPACE) + + + diff --git a/Modules/TestForSTDNamespace.cxx b/Modules/TestForSTDNamespace.cxx new file mode 100644 index 000000000..fc3ac5911 --- /dev/null +++ b/Modules/TestForSTDNamespace.cxx @@ -0,0 +1,6 @@ +#include +int main(int, char*[]) +{ + std::list(); + return 0; +} diff --git a/Modules/Windows.cmake b/Modules/Windows.cmake deleted file mode 100644 index 0c1fa6cc6..000000000 --- a/Modules/Windows.cmake +++ /dev/null @@ -1,4 +0,0 @@ -SET(CMAKE_SHARED_LIBRARY_CREATE_FLAGS "") -SET(CMAKE_DL_LIBS "" ) -SET(CMAKE_SHARED_LIBRARY_PREFIX "") -SET(CMAKE_SHARED_LIBRARY_SUFFIX ".dll") diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 2384b9642..a25f1d79d 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -61,9 +61,7 @@ IF (WIN32) IF(NOT UNIX) SET(SRCS ${SRCS} cmGlobalBorlandMakefileGenerator.cxx - cmLocalBorlandMakefileGenerator.cxx cmGlobalNMakeMakefileGenerator.cxx - cmLocalNMakeMakefileGenerator.cxx cmGlobalVisualStudio6Generator.cxx cmLocalVisualStudio6Generator.cxx cmGlobalVisualStudio7Generator.cxx diff --git a/Source/MFCDialog/CMakeSetupDialog.cpp b/Source/MFCDialog/CMakeSetupDialog.cpp index e5140baf6..a76dc7b8c 100644 --- a/Source/MFCDialog/CMakeSetupDialog.cpp +++ b/Source/MFCDialog/CMakeSetupDialog.cpp @@ -122,6 +122,7 @@ CMakeSetupDialog::CMakeSetupDialog(const CMakeCommandLineInfo& cmdInfo, CWnd* pParent /*=NULL*/) : CDialog(CMakeSetupDialog::IDD, pParent) { + cmSystemTools::SetRunCommandHideConsole(true); cmSystemTools::SetErrorCallback(MFCMessageCallback); m_RegistryKey = "Software\\Kitware\\CMakeSetup\\Settings\\StartPath"; m_CacheEntriesList.m_CMakeSetupDialog = this; diff --git a/Source/TODO b/Source/TODO new file mode 100644 index 000000000..32ff83368 --- /dev/null +++ b/Source/TODO @@ -0,0 +1,52 @@ +Variables: + +CMAKE_SYSTEM + +CMAKE_BUILD_TOOL borlandmake make nmake msdev devenv +CMAKE_MAKE_PROGRAM make nmake msdev devenv *** HAS TO BE IN CACHE for try compile to work +CMAKE_BUILD_TYPE Debug Release RelWithDebInfo MinSizeRel +BUILD_COMMAND needs to be removed + +CMAKE_ANSI_CFLAGS +CMAKE_ANSI_CXXFLAGS +CMAKE_NO_ANSI_STRING_STREAM +CMAKE_NO_STD_NAMESPACE +CMAKE_NO_ANSI_FOR_SCOPE +CMAKE_COMPILER_IS_GNUCXX +CMAKE_NO_EXPLICIT_TEMPLATE_INSTANTIATION + + +CMAKE_CXX_FLAGS +CMAKE_CXX_FLAGS_DEBUG +CMAKE_CXX_FLAGS_MINSIZEREL +CMAKE_CXX_FLAGS_RELEASE +CMAKE_CXX_FLAGS_RELWITHDEBINFO + +CMAKE_C_FLAGS +CMAKE_C_FLAGS_DEBUG +CMAKE_C_FLAGS_MINSIZEREL +CMAKE_C_FLAGS_RELEASE +CMAKE_C_FLAGS_RELWITHDEBINFO + +CMAKE_CXX_LINK_DEBUG_FLAGS +CMAKE_CXX_LINK_RELEASE_FLAGS +CMAKE_CXX_LINK_RELWITHDEBINFO_FLAGS +CMAKE_CXX_LINK_MINSIZEREL_FLAGS + +CMAKE_C_LINK_DEBUG_FLAGS +CMAKE_C_LINK_RELEASE_FLAGS +CMAKE_C_LINK_RELWITHDEBINFO_FLAGS +CMAKE_C_LINK_MINSIZEREL_FLAGS + + +CMAKE_USE_WIN32_THREADS +CMAKE_USE_SPROC +CMAKE_USE_PTHREADS +CMAKE_HP_PTHREADS +CMAKE_THREAD_LIBS +CMAKE_DL_LIBS + +CMAKE_X_LIBS +CMAKE_X_CFLAGS +CMAKE_HAS_X + diff --git a/Source/cmExecProgramCommand.cxx b/Source/cmExecProgramCommand.cxx index 82a56722a..b6159eada 100644 --- a/Source/cmExecProgramCommand.cxx +++ b/Source/cmExecProgramCommand.cxx @@ -118,6 +118,15 @@ bool cmExecProgramCommand::InitialPass(std::vector const& args) { std::string::size_type first = output.find_first_not_of(" \n\t\r"); std::string::size_type last = output.find_last_not_of(" \n\t\r"); + if(first == std::string::npos) + { + first = 0; + } + if(last == std::string::npos) + { + last = output.size()-1; + } + std::string coutput = std::string(output, first, last-first+1); m_Makefile->AddDefinition(output_variable.c_str(), coutput.c_str()); } diff --git a/Source/cmGlobalBorlandMakefileGenerator.cxx b/Source/cmGlobalBorlandMakefileGenerator.cxx index 5fb3612bb..e53fee6aa 100644 --- a/Source/cmGlobalBorlandMakefileGenerator.cxx +++ b/Source/cmGlobalBorlandMakefileGenerator.cxx @@ -15,11 +15,11 @@ =========================================================================*/ #include "cmGlobalBorlandMakefileGenerator.h" -#include "cmLocalBorlandMakefileGenerator.h" +#include "cmLocalUnixMakefileGenerator.h" #include "cmMakefile.h" #include "cmake.h" -void cmGlobalBorlandMakefileGenerator::EnableLanguage(const char*, +void cmGlobalBorlandMakefileGenerator::EnableLanguage(const char* l, cmMakefile *mf) { // now load the settings @@ -37,20 +37,21 @@ void cmGlobalBorlandMakefileGenerator::EnableLanguage(const char*, message += outdir; cmSystemTools::Error(message.c_str()); } - if(!this->GetLanguageEnabled("CXX")) - { - std::string fpath = - mf->GetDefinition("CMAKE_ROOT"); - fpath += "/Templates/CMakeBorlandWindowsSystemConfig.cmake"; - mf->ReadListFile(NULL,fpath.c_str()); - this->SetLanguageEnabled("CXX"); - } + mf->AddDefinition("BORLAND", "1"); + mf->AddDefinition("CMAKE_GENERATOR_CC", "bcc32"); + mf->AddDefinition("CMAKE_GENERATOR_CXX", "bcc32"); + + this->cmGlobalUnixMakefileGenerator::EnableLanguage(l, mf); } ///! Create a local generator appropriate to this Global Generator cmLocalGenerator *cmGlobalBorlandMakefileGenerator::CreateLocalGenerator() { - cmLocalGenerator *lg = new cmLocalBorlandMakefileGenerator; + cmLocalUnixMakefileGenerator *lg = new cmLocalUnixMakefileGenerator; + lg->SetIncludeDirective("!include"); + lg->SetWindowsShell(true); + lg->SetMakefileVariableSize(32); + lg->SetGlobalGenerator(this); return lg; } diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index f7f0ec078..bdb0d147b 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -213,8 +213,7 @@ cmLocalGenerator *cmGlobalGenerator::CreateLocalGenerator() return lg; } -void cmGlobalGenerator::EnableLanguagesFromGenerator(cmGlobalGenerator *gen, - cmMakefile *) +void cmGlobalGenerator::EnableLanguagesFromGenerator(cmGlobalGenerator *gen ) { // create a temp generator cmLocalGenerator *lg = this->CreateLocalGenerator(); diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 9a00b908c..11f37046c 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -79,8 +79,7 @@ public: /** * Try to determine system infomation, get it from another generator */ - virtual void EnableLanguagesFromGenerator(cmGlobalGenerator *gen, - cmMakefile *mf); + virtual void EnableLanguagesFromGenerator(cmGlobalGenerator *gen); /** * Try running cmake and building a file. This is used for dynalically @@ -98,7 +97,9 @@ public: cmake *GetCMakeInstance() { return this->m_CMakeInstance; }; + void SetConfiguredFilesPath(const char* s){m_ConfiguredFilesPath = s;} protected: + cmStdString m_ConfiguredFilesPath; cmake *m_CMakeInstance; std::vector m_LocalGenerators; diff --git a/Source/cmGlobalNMakeMakefileGenerator.cxx b/Source/cmGlobalNMakeMakefileGenerator.cxx index d2bd056df..ce0dbd2ca 100644 --- a/Source/cmGlobalNMakeMakefileGenerator.cxx +++ b/Source/cmGlobalNMakeMakefileGenerator.cxx @@ -15,33 +15,25 @@ =========================================================================*/ #include "cmGlobalNMakeMakefileGenerator.h" -#include "cmLocalNMakeMakefileGenerator.h" +#include "cmLocalUnixMakefileGenerator.h" #include "cmMakefile.h" -void cmGlobalNMakeMakefileGenerator::EnableLanguage(const char*, +void cmGlobalNMakeMakefileGenerator::EnableLanguage(const char* l, cmMakefile *mf) { - // now load the settings - if(!mf->GetDefinition("CMAKE_ROOT")) - { - cmSystemTools::Error( - "CMAKE_ROOT has not been defined, bad GUI or driver program"); - return; - } - if(!this->GetLanguageEnabled("CXX")) - { - std::string fpath = - mf->GetDefinition("CMAKE_ROOT"); - fpath += "/Templates/CMakeNMakeWindowsSystemConfig.cmake"; - mf->ReadListFile(NULL,fpath.c_str()); - this->SetLanguageEnabled("CXX"); - } + // pick a default + mf->AddDefinition("CMAKE_GENERATOR_CC", "cl"); + mf->AddDefinition("CMAKE_GENERATOR_CXX", "cl"); + + this->cmGlobalUnixMakefileGenerator::EnableLanguage(l, mf); } ///! Create a local generator appropriate to this Global Generator cmLocalGenerator *cmGlobalNMakeMakefileGenerator::CreateLocalGenerator() { - cmLocalGenerator *lg = new cmLocalNMakeMakefileGenerator; + cmLocalUnixMakefileGenerator *lg = new cmLocalUnixMakefileGenerator; + lg->SetWindowsShell(true); + lg->SetMakeSilentFlag("/nologo"); lg->SetGlobalGenerator(this); return lg; } diff --git a/Source/cmGlobalNMakeMakefileGenerator.h b/Source/cmGlobalNMakeMakefileGenerator.h index 6bd5734e6..c125cba57 100644 --- a/Source/cmGlobalNMakeMakefileGenerator.h +++ b/Source/cmGlobalNMakeMakefileGenerator.h @@ -41,15 +41,6 @@ public: */ virtual void EnableLanguage(const char*,cmMakefile *mf); - /** - * Try to determine system infomation from another generator - */ - virtual void EnableLanguagesFromGenerator(cmGlobalGenerator *gen, - cmMakefile *mf) - { - this->cmGlobalGenerator::EnableLanguagesFromGenerator(gen,mf); - } - }; #endif diff --git a/Source/cmGlobalUnixMakefileGenerator.cxx b/Source/cmGlobalUnixMakefileGenerator.cxx index ee1454bef..aeb3e413d 100644 --- a/Source/cmGlobalUnixMakefileGenerator.cxx +++ b/Source/cmGlobalUnixMakefileGenerator.cxx @@ -23,47 +23,83 @@ void cmGlobalUnixMakefileGenerator::EnableLanguage(const char* lang, cmMakefile *mf) { - // only do for global runs - if (!m_CMakeInstance->GetLocal()) + // if no lang specified use CXX + if(!lang ) { - std::string output; - std::string root - = cmSystemTools::ConvertToOutputPath(mf->GetDefinition("CMAKE_ROOT")); - // if no lang specified use CXX - if(!lang ) + lang = "CXX"; + } + std::string root + = cmSystemTools::ConvertToOutputPath(mf->GetDefinition("CMAKE_ROOT")); + std::string rootBin = mf->GetHomeOutputDirectory(); + if(m_ConfiguredFilesPath.size()) + { + rootBin = m_ConfiguredFilesPath; + } + bool needCBackwards = false; + bool needCXXBackwards = false; + + // check for a C compiler and configure it + if(!m_CMakeInstance->GetLocal() && + !this->GetLanguageEnabled("C") && + lang[0] == 'C') + { + if (m_CMakeInstance->GetIsInTryCompile()) { - lang = "CXX"; + cmSystemTools::Error("This should not have happen. " + "If you see this message, you are probably using a " + "broken CMakeLists.txt file or a problematic release of " + "CMake"); } - // if CXX or C, then enable C - if((!this->GetLanguageEnabled("C") && lang[0] == 'C')) + needCBackwards = true; + // Read the DetermineSystem file + std::string systemFile = root; + systemFile += "/Modules/CMakeDetermineSystem.cmake"; + mf->ReadListFile(0, systemFile.c_str()); + // read determine C compiler + std::string determineCFile = root; + determineCFile += "/Modules/CMakeDetermineCCompiler.cmake"; + mf->ReadListFile(0,determineCFile.c_str()); + this->SetLanguageEnabled("C"); + } + + // check for a CXX compiler and configure it + if(!m_CMakeInstance->GetLocal() && + !this->GetLanguageEnabled("CXX") && + strcmp(lang, "CXX") == 0) + { + needCXXBackwards = true; + std::string determineCFile = root; + determineCFile += "/Modules/CMakeDetermineCXXCompiler.cmake"; + mf->ReadListFile(0,determineCFile.c_str()); + this->SetLanguageEnabled("CXX"); + } + + + std::string fpath = rootBin; + fpath += "/CMakeSystem.cmake"; + mf->ReadListFile(0,fpath.c_str()); + // if C, then enable C + if(lang[0] == 'C') + { + fpath = rootBin; + fpath += "/CMakeCCompiler.cmake"; + mf->ReadListFile(0,fpath.c_str()); + } + if(strcmp(lang, "CXX") == 0) + { + fpath = rootBin; + fpath += "/CMakeCXXCompiler.cmake"; + mf->ReadListFile(0,fpath.c_str()); + } + fpath = root; + fpath += "/Modules/CMakeSystemSpecificInformation.cmake"; + mf->ReadListFile(0,fpath.c_str()); + if(!m_CMakeInstance->GetLocal()) + { + // At this point we should have enough info for a try compile + // which is used in the backward stuff + if(needCBackwards) { - static char envCC[5000]; - if(mf->GetDefinition("CMAKE_C_COMPILER")) - { - std::string env = "CC=${CMAKE_C_COMPILER}"; - mf->ExpandVariablesInString(env); - strncpy(envCC, env.c_str(), 4999); - envCC[4999] = 0; - putenv(envCC); - } - if (m_CMakeInstance->GetIsInTryCompile()) - { - cmSystemTools::Error("This should not have happen. " - "If you see this message, you are probably using a " - "broken CMakeLists.txt file or a problematic release of " - "CMake"); - } - - std::string cmd = root; - cmd += "/Templates/cconfigure"; - cmSystemTools::RunCommand(cmd.c_str(), output, - cmSystemTools::ConvertToOutputPath( - mf->GetHomeOutputDirectory()).c_str()); - - std::string fpath = mf->GetHomeOutputDirectory(); - fpath += "/CCMakeSystemConfig.cmake"; - mf->ReadListFile(0,fpath.c_str()); - this->SetLanguageEnabled("C"); if (!m_CMakeInstance->GetIsInTryCompile()) { // for old versions of CMake ListFiles @@ -72,41 +108,12 @@ void cmGlobalUnixMakefileGenerator::EnableLanguage(const char* lang, if (!versionValue || atof(versionValue) <= 1.4) { std::string ifpath = root + "/Modules/CMakeBackwardCompatibilityC.cmake"; - mf->ReadListFile(0,ifpath.c_str()); + mf->ReadListFile(0,ifpath.c_str()); } } } - // if CXX - if(!this->GetLanguageEnabled("CXX") && strcmp(lang, "CXX") == 0) + if(needCXXBackwards) { - // see man putenv for explaination of this stupid code.... - static char envCXX[5000]; - if(mf->GetDefinition("CMAKE_CXX_COMPILER")) - { - std::string env = "CXX=${CMAKE_CXX_COMPILER}"; - mf->ExpandVariablesInString(env); - strncpy(envCXX, env.c_str(), 4999); - envCXX[4999] = 0; - putenv(envCXX); - } - std::string cmd = root; - if (m_CMakeInstance->GetIsInTryCompile()) - { - cmSystemTools::Error("This should not have happen. " - "If you see this message, you are probably using a " - "broken CMakeLists.txt file or a problematic release of " - "CMake"); - } - cmd += "/Templates/cxxconfigure"; - cmSystemTools::RunCommand(cmd.c_str(), output, - cmSystemTools::ConvertToOutputPath( - mf->GetHomeOutputDirectory()).c_str()); - - std::string fpath = mf->GetHomeOutputDirectory(); - fpath += "/CXXCMakeSystemConfig.cmake"; - mf->ReadListFile(0,fpath.c_str()); - this->SetLanguageEnabled("CXX"); - if (!m_CMakeInstance->GetIsInTryCompile()) { // for old versions of CMake ListFiles @@ -114,12 +121,11 @@ void cmGlobalUnixMakefileGenerator::EnableLanguage(const char* lang, = mf->GetDefinition("CMAKE_MINIMUM_REQUIRED_VERSION"); if (!versionValue || atof(versionValue) <= 1.4) { - fpath = root + "/Modules/CMakeBackwardCompatibilityCXX.cmake"; - mf->ReadListFile(0,fpath.c_str()); + std::string fpath = root + "/Modules/CMakeBackwardCompatibilityCXX.cmake"; + mf->ReadListFile(0,fpath.c_str()); } } } - // if we are from the top, always define this mf->AddDefinition("RUN_CONFIGURE", true); } @@ -133,33 +139,18 @@ cmLocalGenerator *cmGlobalUnixMakefileGenerator::CreateLocalGenerator() return lg; } -void cmGlobalUnixMakefileGenerator::EnableLanguagesFromGenerator( - cmGlobalGenerator *gen, cmMakefile *mf) +void cmGlobalUnixMakefileGenerator::EnableLanguagesFromGenerator(cmGlobalGenerator *gen) { - // for UNIX we just want to read in the configured files - cmLocalGenerator *lg = this->CreateLocalGenerator(); - - // set the Start directories - lg->GetMakefile()->SetStartDirectory(m_CMakeInstance->GetStartDirectory()); - lg->GetMakefile()->SetStartOutputDirectory(m_CMakeInstance->GetStartOutputDirectory()); - lg->GetMakefile()->MakeStartDirectoriesCurrent(); - + this->SetConfiguredFilesPath(gen->GetCMakeInstance()->GetHomeOutputDirectory()); // if C, then enable C if(gen->GetLanguageEnabled("C")) { - std::string fpath = mf->GetHomeOutputDirectory(); - fpath += "/CCMakeSystemConfig.cmake"; - lg->GetMakefile()->ReadListFile(0,fpath.c_str()); this->SetLanguageEnabled("C"); } // if CXX if(gen->GetLanguageEnabled("CXX")) { - std::string fpath = mf->GetHomeOutputDirectory(); - fpath += "/CXXCMakeSystemConfig.cmake"; - lg->GetMakefile()->ReadListFile(0,fpath.c_str()); this->SetLanguageEnabled("CXX"); } - delete lg; } diff --git a/Source/cmGlobalUnixMakefileGenerator.h b/Source/cmGlobalUnixMakefileGenerator.h index 21a9df25e..895b6a1d5 100644 --- a/Source/cmGlobalUnixMakefileGenerator.h +++ b/Source/cmGlobalUnixMakefileGenerator.h @@ -44,7 +44,7 @@ public: /** * Try to determine system infomation, get it from another generator */ - virtual void EnableLanguagesFromGenerator(cmGlobalGenerator *, cmMakefile *); + virtual void EnableLanguagesFromGenerator(cmGlobalGenerator *); }; diff --git a/Source/cmIfCommand.cxx b/Source/cmIfCommand.cxx index aefec8eae..406416b2d 100644 --- a/Source/cmIfCommand.cxx +++ b/Source/cmIfCommand.cxx @@ -106,7 +106,13 @@ bool cmIfCommand::InitialPass(std::vector const& args) if (!isValid) { - this->SetError("An IF command had incorrect arguments"); + std::string err = "An IF command had incorrect arguments: "; + for(int i =0; i < args.size(); ++i) + { + err += args[i]; + err += " "; + } + this->SetError(err.c_str()); return false; } @@ -177,6 +183,15 @@ bool cmIfCommand::IsTrue(const std::vector &args, bool &isValid, isValid = true; } + if (args.size() == 2 && (args[0] == "MATCHES")) + { + if(!cmSystemTools::FileExists(args[1].c_str())) + { + isTrue = false; + } + isValid = true; + } + if (args.size() == 3 && (args[1] == "AND")) { def = makefile->GetDefinition(args[0].c_str()); @@ -263,7 +278,6 @@ bool cmIfCommand::IsTrue(const std::vector &args, bool &isValid, } isValid = true; } - return isTrue; } diff --git a/Source/cmLoadCommandCommand.cxx b/Source/cmLoadCommandCommand.cxx index 334a97f3c..d5a2f3afe 100644 --- a/Source/cmLoadCommandCommand.cxx +++ b/Source/cmLoadCommandCommand.cxx @@ -176,7 +176,6 @@ bool cmLoadCommandCommand::InitialPass(std::vector const& argsIn) // the file must exist std::string fullPath = cmDynamicLoader::LibPrefix(); fullPath += "cm" + argsIn[0] + cmDynamicLoader::LibExtension(); - std::vector args; cmSystemTools::ExpandListArguments(argsIn, args); @@ -196,7 +195,10 @@ bool cmLoadCommandCommand::InitialPass(std::vector const& argsIn) fullPath = cmSystemTools::FindFile(fullPath.c_str(), path); if (fullPath == "") { - this->SetError("Attempt to load command failed."); + fullPath = "Attempt to load command failed from file : "; + fullPath += cmDynamicLoader::LibPrefix(); + fullPath += "cm" + argsIn[0] + cmDynamicLoader::LibExtension(); + this->SetError(fullPath.c_str()); return false; } diff --git a/Source/cmLocalUnixMakefileGenerator.cxx b/Source/cmLocalUnixMakefileGenerator.cxx index b1279cac8..e96f104e9 100644 --- a/Source/cmLocalUnixMakefileGenerator.cxx +++ b/Source/cmLocalUnixMakefileGenerator.cxx @@ -22,14 +22,13 @@ #include "cmMakeDepend.h" #include "cmCacheManager.h" #include "cmGeneratedFileStream.h" +#include cmLocalUnixMakefileGenerator::cmLocalUnixMakefileGenerator() - :m_SharedLibraryExtension("$(SHLIB_SUFFIX)"), - m_ObjectFileExtension(".o"), - m_ExecutableExtension(cmSystemTools::GetExecutableExtension()), - m_StaticLibraryExtension(".a"), - m_LibraryPrefix("lib") { + m_WindowsShell = false; + m_IncludeDirective = "include"; + m_MakefileVariableSize = 0; } cmLocalUnixMakefileGenerator::~cmLocalUnixMakefileGenerator() @@ -203,8 +202,11 @@ void cmLocalUnixMakefileGenerator::OutputMakefile(const char* file, fout << "# " << i->c_str() << "\n"; } fout << "\n\n"; - fout << "# Suppresses display of executed commands\n"; - fout << ".SILENT:\n"; + if(!m_Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE")) + { + fout << "# Suppresses display of executed commands\n"; + fout << ".SILENT:\n"; + } fout << "# disable some common implicit rules to speed things up\n"; fout << ".SUFFIXES:\n"; fout << ".SUFFIXES:.hpuxmakemusthaverule\n"; @@ -275,21 +277,33 @@ void cmLocalUnixMakefileGenerator::OutputMakefile(const char* file, // only add the depend include if the depend file exists if(cmSystemTools::FileExists(dependName.c_str())) { - this->OutputIncludeMakefile(fout, "cmake.depends"); + fout << m_IncludeDirective << " cmake.depends\n"; } } -void cmLocalUnixMakefileGenerator::OutputIncludeMakefile(std::ostream& fout, - const char* file) -{ - fout << "include " << file << "\n"; -} std::string -cmLocalUnixMakefileGenerator::GetOutputExtension(const char*) +cmLocalUnixMakefileGenerator::GetOutputExtension(const char* s) { - return m_ObjectFileExtension; + std::string sourceExtension = s; +#if defined(_WIN32) && ! defined(__CYGWIN__) + if(sourceExtension == "def") + { + return ""; + } + if(sourceExtension == "ico" || sourceExtension == "rc2") + { + return ""; + } + if(sourceExtension == "rc") + { + return ".res"; + } + return ".obj"; +#else + return ".o"; +#endif } @@ -306,24 +320,31 @@ void cmLocalUnixMakefileGenerator::OutputTargetRules(std::ostream& fout) { if (l->second.IsInAll()) { - std::string path = m_LibraryOutputPath + m_LibraryPrefix; + std::string path = m_LibraryOutputPath; if(l->second.GetType() == cmTarget::STATIC_LIBRARY) { - path = path + l->first + m_StaticLibraryExtension; + path += + this->GetSafeDefinition("CMAKE_STATIC_LIBRARY_PREFIX") + + l->first + + this->GetSafeDefinition("CMAKE_STATIC_LIBRARY_SUFFIX"); fout << " \\\n" << cmSystemTools::ConvertToOutputPath(path.c_str()); } else if(l->second.GetType() == cmTarget::SHARED_LIBRARY) { - path = path + l->first + - m_Makefile->GetDefinition("CMAKE_SHLIB_SUFFIX"); + path += + this->GetSafeDefinition("CMAKE_SHARED_LIBRARY_PREFIX") + + l->first + + this->GetSafeDefinition("CMAKE_SHARED_LIBRARY_SUFFIX"); fout << " \\\n" << cmSystemTools::ConvertToOutputPath(path.c_str()); } else if(l->second.GetType() == cmTarget::MODULE_LIBRARY) { - path = path + l->first + - m_Makefile->GetDefinition("CMAKE_MODULE_SUFFIX"); + path += + this->GetSafeDefinition("CMAKE_SHARED_MODULE_PREFIX") + + l->first + + this->GetSafeDefinition("CMAKE_SHARED_MODULE_SUFFIX"); fout << " \\\n" << cmSystemTools::ConvertToOutputPath(path.c_str()); } @@ -338,7 +359,7 @@ void cmLocalUnixMakefileGenerator::OutputTargetRules(std::ostream& fout) l->second.IsInAll()) { std::string path = m_ExecutableOutputPath + l->first + - m_ExecutableExtension; + cmSystemTools::GetExecutableExtension(); fout << " \\\n" << cmSystemTools::ConvertToOutputPath(path.c_str()); } } @@ -366,10 +387,12 @@ void cmLocalUnixMakefileGenerator::OutputTargetRules(std::ostream& fout) { if(!(*i)->GetPropertyAsBool("HEADER_FILE_ONLY")) { - std::string outExt(this->GetOutputExtension((*i)->GetSourceExtension().c_str())); + std::string outExt( + this->GetOutputExtension((*i)->GetSourceExtension().c_str())); if(outExt.size()) { - fout << "\\\n" << cmSystemTools::ConvertToOutputPath((*i)->GetSourceName().c_str()) + fout << "\\\n" + << cmSystemTools::ConvertToOutputPath((*i)->GetSourceName().c_str()) << outExt.c_str() << " "; } } @@ -441,38 +464,28 @@ void cmLocalUnixMakefileGenerator::OutputLinkLibraries(std::ostream& fout, // and may have different flags if( tgt.GetType() == cmTarget::EXECUTABLE) { - if(m_Makefile->GetDefinition("CMAKE_C_SHLIB_RUNTIME_FLAG")) - { - runtimeFlag = m_Makefile->GetDefinition("CMAKE_C_SHLIB_RUNTIME_FLAG"); - } + runtimeFlag = this->GetSafeDefinition("CMAKE_SHARED_LIBRARY_LINK_FLAGS"); } else { - if(m_Makefile->GetDefinition("CMAKE_SHLIB_RUNTIME_FLAG")) - { - runtimeFlag = m_Makefile->GetDefinition("CMAKE_SHLIB_RUNTIME_FLAG"); - } + runtimeFlag = this->GetSafeDefinition("CMAKE_SHARED_LIBRARY_RUNTIME_FLAG"); } - if(m_Makefile->GetDefinition("CMAKE_SHLIB_RUNTIME_SEP")) - { - runtimeSep = m_Makefile->GetDefinition("CMAKE_SHLIB_RUNTIME_SEP"); - } + runtimeSep = this->GetSafeDefinition("CMAKE_SHARED_LIBRARY_RUNTIME_FLAG_SEP"); } else - { - if(m_Makefile->GetDefinition("CMAKE_CXX_SHLIB_RUNTIME_FLAG")) + { + if( tgt.GetType() == cmTarget::EXECUTABLE) { - runtimeFlag = m_Makefile->GetDefinition("CMAKE_CXX_SHLIB_RUNTIME_FLAG"); + runtimeFlag = this->GetSafeDefinition("CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS"); } - - if(m_Makefile->GetDefinition("CMAKE_CXX_SHLIB_RUNTIME_SEP")) + else { - runtimeSep = m_Makefile->GetDefinition("CMAKE_CXX_SHLIB_RUNTIME_SEP"); - } + runtimeFlag = this->GetSafeDefinition("CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG"); + } + runtimeFlag = this->GetSafeDefinition("CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG"); + runtimeSep = this->GetSafeDefinition("CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG_SEP"); } - - // concatenate all paths or no? bool runtimeConcatenate = ( runtimeSep!="" ); if(runtimeFlag == "" || m_Makefile->IsOn("CMAKE_SKIP_RPATH") ) @@ -483,7 +496,8 @@ void cmLocalUnixMakefileGenerator::OutputLinkLibraries(std::ostream& fout, // Some search paths should never be emitted emitted.insert(""); emitted.insert("/usr/lib"); - + std::string libPathFlag = m_Makefile->GetDefinition("CMAKE_LIBRARY_PATH_FLAG"); + std::string libLinkFlag = this->GetSafeDefinition("CMAKE_LINK_LIBRARY_FLAG"); // collect all the flags needed for linking libraries std::string linkLibs; const std::vector& libdirs = tgt.GetLinkDirectories(); @@ -493,11 +507,11 @@ void cmLocalUnixMakefileGenerator::OutputLinkLibraries(std::ostream& fout, std::string libpath = cmSystemTools::ConvertToOutputPath(libDir->c_str()); if(emitted.insert(libpath).second) { - std::string::size_type pos = libDir->find("-L"); + std::string::size_type pos = libDir->find(libPathFlag.c_str()); if((pos == std::string::npos || pos > 0) && libDir->find("${") == std::string::npos) { - linkLibs += "-L"; + linkLibs += libPathFlag; if(outputRuntime) { runtimeDirs.push_back( libpath ); @@ -508,6 +522,11 @@ void cmLocalUnixMakefileGenerator::OutputLinkLibraries(std::ostream& fout, } } + std::string linkSuffix = this->GetSafeDefinition("CMAKE_LINK_LIBRARY_SUFFIX"); + std::string regexp = ".*\\"; + regexp += linkSuffix; + regexp += "$"; + cmRegularExpression hasSuffix(linkSuffix.c_str()); std::string librariesLinked; const cmTarget::LinkLibraries& libs = tgt.GetLinkLibraries(); for(cmTarget::LinkLibraries::const_iterator lib = libs.begin(); @@ -531,28 +550,37 @@ void cmLocalUnixMakefileGenerator::OutputLinkLibraries(std::ostream& fout, std::string libpath = cmSystemTools::ConvertToOutputPath(dir.c_str()); if(emitted.insert(libpath).second) { - linkLibs += "-L"; + linkLibs += libPathFlag; linkLibs += libpath; linkLibs += " "; if(outputRuntime) { runtimeDirs.push_back( libpath ); } - } + } + cmRegularExpression reg(regexp.c_str()); cmRegularExpression libname("lib(.*)(\\.so|\\.sl|\\.a|\\.dylib).*"); cmRegularExpression libname_noprefix("(.*)(\\.so|\\.sl|\\.a|\\.dylib).*"); if(libname.find(file)) { - librariesLinked += "-l"; + librariesLinked += libLinkFlag; file = libname.match(1); librariesLinked += file; + if(linkSuffix.size() && !hasSuffix.find(file)) + { + librariesLinked += linkSuffix; + } librariesLinked += " "; } else if(libname_noprefix.find(file)) { - librariesLinked += "-l"; + librariesLinked += libLinkFlag; file = libname_noprefix.match(1); librariesLinked += file; + if(linkSuffix.size() && !hasSuffix.find(file)) + { + librariesLinked += linkSuffix; + } librariesLinked += " "; } } @@ -561,9 +589,13 @@ void cmLocalUnixMakefileGenerator::OutputLinkLibraries(std::ostream& fout, { if(!reg.find(lib->first)) { - librariesLinked += "-l"; + librariesLinked += libLinkFlag; } librariesLinked += lib->first; + if(linkSuffix.size() && !hasSuffix.find(lib->first)) + { + librariesLinked += linkSuffix; + } librariesLinked += " "; } } @@ -593,6 +625,10 @@ void cmLocalUnixMakefileGenerator::OutputLinkLibraries(std::ostream& fout, } fout << " "; } + if(m_Makefile->GetDefinition("CMAKE_STANDARD_LIBRARIES")) + { + fout << m_Makefile->GetDefinition("CMAKE_STANDARD_LIBRARIES") << " "; + } } @@ -624,91 +660,187 @@ std::string cmLocalUnixMakefileGenerator::CreateTargetRules(const cmTarget &targ return customRuleCode; } +struct RuleVariables +{ + const char* replace; + const char* lookup; +}; + +static RuleVariables ruleReplaceVars[] = +{ + {"", "CMAKE_CXX_COMPILER"}, + {"", "CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS"}, + {"", "CMAKE_SHARED_MODULE_CREATE_CXX_FLAGS"}, + {"", "CMAKE_CXX_LINK_FLAGS"}, + + {"", "CMAKE_C_COMPILER"}, + {"", "CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS"}, + {"", "CMAKE_SHARED_MODULE_CREATE_C_FLAGS"}, + {"", "CMAKE_C_LINK_FLAGS"}, + + {"", "CMAKE_AR"}, + {"", "CMAKE_RANLIB"}, + {0} +}; + + + + +void +cmLocalUnixMakefileGenerator::ExpandRuleVariables(std::string& s, + const char* objects, + const char* target, + const char* linkLibs, + const char* source, + const char* object, + const char* flags, + const char* objectsquoted, + const char* targetBase) +{ + if(flags) + { + cmSystemTools::ReplaceString(s, "", flags); + } + + if(source) + { + cmSystemTools::ReplaceString(s, "", source); + } + if(object) + { + cmSystemTools::ReplaceString(s, "", object); + } + if(objects) + { + cmSystemTools::ReplaceString(s, "", objects); + } + if(objectsquoted) + { + cmSystemTools::ReplaceString(s, "", objectsquoted); + } + if(target) + { + cmSystemTools::ReplaceString(s, "", target); + } + if(targetBase) + { + cmSystemTools::ReplaceString(s, "", targetBase); + } + if(linkLibs) + { + cmSystemTools::ReplaceString(s, "", linkLibs); + } + + RuleVariables* rv = ruleReplaceVars; + while(rv->replace) + { + cmSystemTools::ReplaceString(s, rv->replace, + this->GetSafeDefinition(rv->lookup)); + rv++; + } +} + + +void cmLocalUnixMakefileGenerator::OutputLibraryRule(std::ostream& fout, + const char* name, + const cmTarget &t, + const char* prefix, + const char* suffix, + const char* createVariable, + const char* comment + ) +{ + // create the library name + std::string targetNameBase = prefix; + targetNameBase += name; + + std::string targetName = prefix; + targetName += name; + targetName += suffix; + // create the target full path name + std::string targetFullPath = m_LibraryOutputPath + targetName; + std::string targetBaseFullPath = m_LibraryOutputPath + targetNameBase; + targetBaseFullPath = + cmSystemTools::ConvertToOutputPath(targetBaseFullPath.c_str()); + targetFullPath = cmSystemTools::ConvertToOutputPath(targetFullPath.c_str()); + // get the objects that are used to link this library + std::string objs = "$(" + this->CreateMakeVariable(name, "_SRC_OBJS") + ") "; + std::string objsQuoted = "$(" + this->CreateMakeVariable(name, "_SRC_OBJS_QUOTED") + ") "; + // create a variable with the objects that this library depends on + std::string depend = objs + " $(" + + this->CreateMakeVariable(name, "_DEPEND_LIBS") + ")"; + // collect up the build rules + std::vector rules; + std::string command = "$(RM) " + targetFullPath; + rules.push_back(command); + rules.push_back(m_Makefile->GetDefinition(createVariable)); + // expand multi-command semi-colon separated lists + // of commands into separate commands + std::vector commands; + cmSystemTools::ExpandListArguments(rules, commands); + // collect custom commands for this target and add them to the list + std::string customCommands = this->CreateTargetRules(t, name); + if(customCommands.size() > 0) + { + commands.push_back(customCommands); + } + // collect up the link libraries + cmOStringStream linklibs; + this->OutputLinkLibraries(linklibs, name, t); + for(std::vector::iterator i = commands.begin(); + i != commands.end(); ++i) + { + this->ExpandRuleVariables(*i, + objs.c_str(), + targetFullPath.c_str(), + linklibs.str().c_str(), + 0, 0, 0, objsQuoted.c_str(), + targetBaseFullPath.c_str()); + } + this->OutputMakeRule(fout, comment, + targetFullPath.c_str(), + depend.c_str(), + commands); +} void cmLocalUnixMakefileGenerator::OutputSharedLibraryRule(std::ostream& fout, - const char* name, - const cmTarget &t) + const char* name, + const cmTarget &t) { - std::string target = m_LibraryOutputPath + "lib" + name + "$(SHLIB_SUFFIX)"; - std::string depend = "$("; - depend += this->CreateMakeVariable(name, "_SRC_OBJS"); - depend += ") $(" + this->CreateMakeVariable(name, "_DEPEND_LIBS") + ")"; - std::string command = "$(RM) lib"; - command += name; - command += "$(SHLIB_SUFFIX)"; - std::string command2; + const char* createRule; if(t.HasCxx()) { - command2 = "$(CMAKE_CXX_LINK_SHARED) $(CMAKE_CXX_SHLIB_LINK_FLAGS) " - "$(CMAKE_CXX_SHLIB_BUILD_FLAGS) $(CMAKE_CXX_FLAGS) -o \\\n"; + createRule = "CMAKE_CXX_CREATE_SHARED_LIBRARY"; } else { - command2 = "$(CMAKE_C_LINK_SHARED) $(CMAKE_SHLIB_LINK_FLAGS) " - "$(CMAKE_SHLIB_BUILD_FLAGS) -o \\\n"; + createRule = "CMAKE_C_CREATE_SHARED_LIBRARY"; } - command2 += "\t "; - std::string libName = m_LibraryOutputPath + "lib" + std::string(name) + "$(SHLIB_SUFFIX)"; - libName = cmSystemTools::ConvertToOutputPath(libName.c_str()); - command2 += libName + " \\\n"; - command2 += "\t $(" + this->CreateMakeVariable(name, "_SRC_OBJS") + ") "; - cmOStringStream linklibs; - this->OutputLinkLibraries(linklibs, name, t); - command2 += linklibs.str(); - std::string customCommands = this->CreateTargetRules(t, name); - const char* cc = 0; - if(customCommands.size() > 0) - { - cc = customCommands.c_str(); - } - this->OutputMakeRule(fout, "rules for a shared library", - target.c_str(), - depend.c_str(), - command.c_str(), - command2.c_str(), - cc); + this->OutputLibraryRule(fout, name, t, + this->GetSafeDefinition("CMAKE_SHARED_LIBRARY_PREFIX"), + this->GetSafeDefinition("CMAKE_SHARED_LIBRARY_SUFFIX"), + createRule, + "shared library"); } void cmLocalUnixMakefileGenerator::OutputModuleLibraryRule(std::ostream& fout, const char* name, const cmTarget &t) { - std::string target = m_LibraryOutputPath + "lib" + std::string(name) + "$(MODULE_SUFFIX)"; - std::string depend = "$("; - depend += this->CreateMakeVariable(name, "_SRC_OBJS") - + ") $(" + this->CreateMakeVariable(name, "_DEPEND_LIBS") + ")"; - std::string command = "$(RM) lib" + std::string(name) + "$(MODULE_SUFFIX)"; - std::string command2; + const char* createRule; if(t.HasCxx()) { - command2 = "$(CMAKE_CXX_LINK_SHARED) $(CMAKE_CXX_MODULE_LINK_FLAGS) " - "$(CMAKE_CXX_MODULE_BUILD_FLAGS) $(CMAKE_CXX_FLAGS) -o \\\n"; + createRule = "CMAKE_CXX_CREATE_SHARED_MODULE"; } else { - command2 = "$(CMAKE_C_LINK_SHARED) $(CMAKE_SHLIB_LINK_FLAGS) " - "$(CMAKE_MODULE_BUILD_FLAGS) -o \\\n"; + createRule = "CMAKE_C_CREATE_SHARED_MODULE"; } - command2 += "\t "; - std::string libName = m_LibraryOutputPath + "lib" + std::string(name) + "$(MODULE_SUFFIX)"; - libName = cmSystemTools::ConvertToOutputPath(libName.c_str()); - command2 += libName + " \\\n"; - command2 += "\t $(" + this->CreateMakeVariable(name, "_SRC_OBJS") + ") "; - cmOStringStream linklibs; - this->OutputLinkLibraries(linklibs, std::string(name).c_str(), t); - command2 += linklibs.str(); - std::string customCommands = this->CreateTargetRules(t, name); - const char* cc = 0; - if(customCommands.size() > 0) - { - cc = customCommands.c_str(); - } - this->OutputMakeRule(fout, "rules for a shared module library", - target.c_str(), - depend.c_str(), - command.c_str(), - command2.c_str(), - cc); + this->OutputLibraryRule(fout, name, t, + this->GetSafeDefinition("CMAKE_SHARED_MODULE_PREFIX"), + this->GetSafeDefinition("CMAKE_SHARED_MODULE_SUFFIX"), + createRule, + "shared module"); } @@ -716,81 +848,85 @@ void cmLocalUnixMakefileGenerator::OutputStaticLibraryRule(std::ostream& fout, const char* name, const cmTarget &t) { - std::string target = m_LibraryOutputPath + "lib" + std::string(name) + ".a"; - target = cmSystemTools::ConvertToOutputPath(target.c_str()); - std::string depend = "$("; - depend += this->CreateMakeVariable(name, "_SRC_OBJS") + ")"; - std::string command; + const char* createRule; if(t.HasCxx()) { - command = "$(CMAKE_CXX_AR) $(CMAKE_CXX_AR_ARGS) "; + createRule = "CMAKE_CXX_CREATE_STATIC_LIBRARY"; } else { - command = "$(CMAKE_AR) $(CMAKE_AR_ARGS) "; + createRule = "CMAKE_C_CREATE_STATIC_LIBRARY"; } - command += target; - command += " $("; - command += this->CreateMakeVariable(name, "_SRC_OBJS") + ")"; - std::string command2 = "$(CMAKE_RANLIB) "; - command2 += target; - std::string comment = "rule to build static library: "; - comment += name; - std::string customCommands = this->CreateTargetRules(t, name); - const char* cc = 0; - if(customCommands.size() > 0) - { - cc = customCommands.c_str(); - } - this->OutputMakeRule(fout, - comment.c_str(), - target.c_str(), - depend.c_str(), - command.c_str(), - command2.c_str(), - cc); + this->OutputLibraryRule(fout, name, t, + this->GetSafeDefinition("CMAKE_STATIC_LIBRARY_PREFIX"), + this->GetSafeDefinition("CMAKE_STATIC_LIBRARY_SUFFIX"), + createRule, + "static library"); + } void cmLocalUnixMakefileGenerator::OutputExecutableRule(std::ostream& fout, const char* name, const cmTarget &t) { - std::string target = m_ExecutableOutputPath + name + m_ExecutableExtension; + std::string flags; + std::string target = m_ExecutableOutputPath + name + + cmSystemTools::GetExecutableExtension(); + std::string objs = "$(" + this->CreateMakeVariable(name, "_SRC_OBJS") + ") "; std::string depend = "$("; depend += this->CreateMakeVariable(name, "_SRC_OBJS") + ") $(" + this->CreateMakeVariable(name, "_DEPEND_LIBS") + ")"; - std::string command; + std::vector rules; if(t.HasCxx()) { - command = - "$(CMAKE_CXX_COMPILER) $(CMAKE_CXX_SHLIB_LINK_FLAGS) $(CMAKE_CXX_FLAGS) "; + rules.push_back(m_Makefile->GetDefinition("CMAKE_CXX_LINK_EXECUTABLE")); + flags += this->GetSafeDefinition("CMAKE_CXX_FLAGS"); + flags += " "; } else { - command = - "$(CMAKE_C_COMPILER) $(CMAKE_C_SHLIB_LINK_FLAGS) $(CMAKE_C_FLAGS) "; + rules.push_back(m_Makefile->GetDefinition("CMAKE_C_LINK_EXECUTABLE")); + flags += this->GetSafeDefinition("CMAKE_C_FLAGS"); + flags += " "; } - command += "$(" + this->CreateMakeVariable(name, "_SRC_OBJS") + ") "; cmOStringStream linklibs; this->OutputLinkLibraries(linklibs, 0, t); - command += linklibs.str(); - std::string outputFile = m_ExecutableOutputPath + name; - command += " -o " + cmSystemTools::ConvertToOutputPath(outputFile.c_str()); - std::string comment = "rule to build executable: "; - comment += name; + std::string comment = "executable"; + std::vector commands; + cmSystemTools::ExpandListArguments(rules, commands); std::string customCommands = this->CreateTargetRules(t, name); - const char* cc = 0; if(customCommands.size() > 0) { - cc = customCommands.c_str(); + commands.push_back(customCommands.c_str()); + } + std::string linkFlags; + if(t.GetType() == cmTarget::WIN32_EXECUTABLE) + { + linkFlags += this->GetSafeDefinition("CMAKE_CREATE_WIN32_EXE"); + linkFlags += " "; + } + else + { + linkFlags += this->GetSafeDefinition("CMAKE_CREATE_CONSOLE_EXE"); + linkFlags += " "; + } + + for(std::vector::iterator i = commands.begin(); + i != commands.end(); ++i) + { + cmSystemTools::ReplaceString(*i, "", linkFlags.c_str()); + this->ExpandRuleVariables(*i, + objs.c_str(), + target.c_str(), + linklibs.str().c_str(), + 0, 0, flags.c_str()); } this->OutputMakeRule(fout, comment.c_str(), target.c_str(), depend.c_str(), - command.c_str(), - cc); + commands); } @@ -805,8 +941,7 @@ void cmLocalUnixMakefileGenerator::OutputUtilityRule(std::ostream& fout, { cc = customCommands.c_str(); } - std::string comment = "Rule to build Utility "; - comment += name; + std::string comment = "Utility"; std::string depends; std::string replaceVars; const std::vector &ccs = t.GetCustomCommands(); @@ -953,20 +1088,25 @@ void cmLocalUnixMakefileGenerator::OutputDependLibs(std::ostream& fout) // if it was a library.. if (libType) { - std::string library = m_LibraryPrefix; - library += *lib; + std::string library; std::string libpath = cacheValue; if(libType && std::string(libType) == "SHARED") { - library += m_Makefile->GetDefinition("CMAKE_SHLIB_SUFFIX"); + library = this->GetSafeDefinition("CMAKE_SHARED_LIBRARY_PREFIX"); + library += *lib; + library += this->GetSafeDefinition("CMAKE_SHARED_LIBRARY_SUFFIX"); } else if(libType && std::string(libType) == "MODULE") { - library += m_Makefile->GetDefinition("CMAKE_MODULE_SUFFIX"); + library = this->GetSafeDefinition("CMAKE_SHARED_MODULE_PREFIX"); + library += *lib; + library += this->GetSafeDefinition("CMAKE_SHARED_MODULE_SUFFIX"); } else if(libType && std::string(libType) == "STATIC") { - library += m_StaticLibraryExtension; + library = this->GetSafeDefinition("CMAKE_STATIC_LIBRARY_PREFIX"); + library += *lib; + library += this->GetSafeDefinition("CMAKE_STATIC_LIBRARY_SUFFIX"); } else { @@ -1039,7 +1179,17 @@ void cmLocalUnixMakefileGenerator::OutputBuildTargetInDir(std::ostream& fout, bool cmLocalUnixMakefileGenerator::SamePath(const char* path1, const char* path2) { - return strcmp(path1, path2) == 0; + if (strcmp(path1, path2) == 0) + { + return true; + } +#if defined(_WIN32) || defined(__APPLE__) + return + cmSystemTools::LowerCase(this->ConvertToOutputForExisting(path1)) == + cmSystemTools::LowerCase(this->ConvertToOutputForExisting(path2)); +#else + return false; +#endif } void cmLocalUnixMakefileGenerator::OutputLibDepend(std::ostream& fout, @@ -1060,38 +1210,39 @@ void cmLocalUnixMakefileGenerator::OutputLibDepend(std::ostream& fout, if(m_LibraryOutputPath.size()) { libpath = m_LibraryOutputPath; - libpath += m_LibraryPrefix; } else { libpath = cacheValue; libpath += "/"; - libpath += m_LibraryPrefix; } } else { // library is in current Makefile so use lib as a prefix libpath = m_LibraryOutputPath; - libpath += m_LibraryPrefix; } - // add the library name - libpath += name; // add the correct extension std::string ltname = name; ltname += "_LIBRARY_TYPE"; const char* libType = m_Makefile->GetDefinition(ltname.c_str()); if(libType && std::string(libType) == "SHARED") { - libpath += m_Makefile->GetDefinition("CMAKE_SHLIB_SUFFIX"); + libpath += this->GetSafeDefinition("CMAKE_SHARED_LIBRARY_PREFIX"); + libpath += name; + libpath += this->GetSafeDefinition("CMAKE_SHARED_LIBRARY_SUFFIX"); } else if (libType && std::string(libType) == "MODULE") { - libpath += m_Makefile->GetDefinition("CMAKE_MODULE_SUFFIX"); + libpath += this->GetSafeDefinition("CMAKE_SHARED_MODULE_PREFIX"); + libpath += name; + libpath += this->GetSafeDefinition("CMAKE_SHARED_MODULE_SUFFIX"); } else if (libType && std::string(libType) == "STATIC") { - libpath += m_StaticLibraryExtension; + libpath += this->GetSafeDefinition("CMAKE_STATIC_LIBRARY_PREFIX"); + libpath += name; + libpath += this->GetSafeDefinition("CMAKE_STATIC_LIBRARY_SUFFIX"); } fout << cmSystemTools::ConvertToOutputPath(libpath.c_str()) << " "; } @@ -1131,7 +1282,7 @@ void cmLocalUnixMakefileGenerator::OutputExeDepend(std::ostream& fout, // add the library name exepath += name; // add the correct extension - exepath += m_ExecutableExtension; + exepath += cmSystemTools::GetExecutableExtension(); fout << cmSystemTools::ConvertToOutputPath(exepath.c_str()) << " "; } } @@ -1160,12 +1311,50 @@ inline std::string FixDirectoryName(const char* dir) } +void cmLocalUnixMakefileGenerator::BuildInSubDirectoryWindows(std::ostream& fout, + const char* directory, + const char* target1, + const char* target2, + bool silent) +{ + if(target1) + { + std::string dir = cmSystemTools::ConvertToOutputPath(directory); + fout << "\tif not exist \"" << dir << "\\$(NULL)\"" + << " " + << "$(MAKE) $(MAKESILENT) rebuild_cache\n"; + if (!silent) + { + fout << "\techo " << directory << ": building " << target1 << "\n"; + } + fout << "\tcd " << dir << "\n" + << "\t$(MAKE) -$(MAKEFLAGS) $(MAKESILENT) " << target1 << "\n"; + } + if(target2) + { + if (!silent) + { + fout << "\techo " << directory << ": building " << target2 << "\n"; + } + fout << "\t$(MAKE) -$(MAKEFLAGS) $(MAKESILENT) " << target2 << "\n"; + } + std::string currentDir = m_Makefile->GetCurrentOutputDirectory(); + fout << "\tcd " << cmSystemTools::ConvertToOutputPath(currentDir.c_str()) << "\n\n"; +} + + void cmLocalUnixMakefileGenerator::BuildInSubDirectory(std::ostream& fout, const char* dir, const char* target1, const char* target2, bool silent) { + if(m_WindowsShell) + { + this->BuildInSubDirectoryWindows(fout, dir, target1, target2, silent); + return; + } + std::string directory = cmSystemTools::ConvertToOutputPath(dir); if(target1) { @@ -1313,7 +1502,9 @@ bool cmLocalUnixMakefileGenerator::OutputObjectDepends(std::ostream& fout) (*source)->GetDepends().begin(); dep != (*source)->GetDepends().end(); ++dep) { - fout << (*source)->GetSourceName() << m_ObjectFileExtension << " : " + fout << (*source)->GetSourceName() + << this->GetOutputExtension( + (*source)->GetSourceExtension().c_str()) << " : " << cmSystemTools::ConvertToOutputPath(dep->c_str()) << "\n"; ret = true; } @@ -1511,69 +1702,65 @@ void cmLocalUnixMakefileGenerator::OutputCustomRules(std::ostream& fout) } } +std::string +cmLocalUnixMakefileGenerator::ConvertToOutputForExisting(const char* p) +{ + std::string ret = cmSystemTools::ConvertToOutputPath(p); + cmSystemTools::GetShortPath(ret.c_str(), ret); + return ret; +} + + void cmLocalUnixMakefileGenerator::OutputMakeVariables(std::ostream& fout) { const char* variables = "# the standard shell for make\n" "SHELL = /bin/sh\n" - "\n" - "CMAKE_RANLIB = @CMAKE_RANLIB@\n" - "CMAKE_AR = @CMAKE_AR@\n" - "CMAKE_AR_ARGS = @CMAKE_AR_ARGS@\n" - "CMAKE_CXX_AR = @CMAKE_CXX_AR@\n" - "CMAKE_CXX_AR_ARGS = @CMAKE_CXX_AR_ARGS@\n" - "CMAKE_C_FLAGS = @CMAKE_C_FLAGS@\n" - "CMAKE_C_COMPILER = @CMAKE_C_COMPILER@\n" - "CMAKE_C_LINK_SHARED = @CMAKE_C_LINK_SHARED@\n" - "CMAKE_CXX_LINK_SHARED = @CMAKE_CXX_LINK_SHARED@\n" - "CMAKE_SHLIB_CFLAGS = @CMAKE_SHLIB_CFLAGS@\n" - - "CMAKE_CXX_SHLIB_CFLAGS = @CMAKE_CXX_SHLIB_CFLAGS@\n" - "CMAKE_CXX_SHLIB_BUILD_FLAGS = @CMAKE_CXX_SHLIB_BUILD_FLAGS@\n" - "CMAKE_CXX_SHLIB_LINK_FLAGS = @CMAKE_CXX_SHLIB_LINK_FLAGS@\n" - "CMAKE_CXX_MODULE_BUILD_FLAGS = @CMAKE_CXX_MODULE_BUILD_FLAGS@\n" - "CMAKE_CXX_MODULE_LINK_FLAGS = @CMAKE_CXX_MODULE_LINK_FLAGS@\n" - "CMAKE_CXX_SHLIB_RUNTIME_FLAG = @CMAKE_CXX_SHLIB_RUNTIME_FLAG@\n" - "CMAKE_CXX_SHLIB_RUNTIME_SEP = @CMAKE_CXX_SHLIB_RUNTIME_SEP@\n" - - "\n" - "CMAKE_CXX_COMPILER = @CMAKE_CXX_COMPILER@\n" - "CMAKE_CXX_FLAGS = @CMAKE_CXX_FLAGS@\n" - "\n" - "CMAKE_SHLIB_BUILD_FLAGS = @CMAKE_SHLIB_BUILD_FLAGS@\n" - "CMAKE_SHLIB_LINK_FLAGS = @CMAKE_SHLIB_LINK_FLAGS@\n" - "CMAKE_C_SHLIB_LINK_FLAGS = @CMAKE_C_SHLIB_LINK_FLAGS@\n" - "CMAKE_MODULE_BUILD_FLAGS = @CMAKE_MODULE_BUILD_FLAGS@\n" - "CMAKE_MODULE_LINK_FLAGS = @CMAKE_MODULE_LINK_FLAGS@\n" - "CMAKE_C_SHLIB_RUNTIME_FLAG = @CMAKE_C_SHLIB_RUNTIME_FLAG@\n" - "CMAKE_SHLIB_RUNTIME_FLAG = @CMAKE_SHLIB_RUNTIME_FLAG@\n" - "CMAKE_SHLIB_RUNTIME_SEP = @CMAKE_SHLIB_RUNTIME_SEP@\n" - "SHLIB_LD_LIBS = @CMAKE_SHLIB_LD_LIBS@\n" - "SHLIB_SUFFIX = @CMAKE_SHLIB_SUFFIX@\n" - "MODULE_SUFFIX = @CMAKE_MODULE_SUFFIX@\n" - "RM = rm -f\n" "\n"; - std::string replaceVars = variables; - m_Makefile->ExpandVariablesInString(replaceVars); - fout << replaceVars.c_str(); + if(!m_WindowsShell) + { + fout << variables; + } + else + { + fout << + "!IF \"$(OS)\" == \"Windows_NT\"\n" + "NULL=\n" + "!ELSE \n" + "NULL=nul\n" + "!ENDIF \n"; + } + if(m_MakeSilentFlag.size()) + { + fout << "MAKESILENT = " << m_MakeSilentFlag << "\n"; + } + + std::string cmakecommand = this->ConvertToOutputForExisting( + m_Makefile->GetDefinition("CMAKE_COMMAND")); fout << "CMAKE_COMMAND = " - << cmSystemTools::ConvertToOutputPath(m_Makefile->GetDefinition("CMAKE_COMMAND")) + << cmakecommand << "\n"; + fout << "RM = " << cmakecommand.c_str() << " -E remove -f\n"; + if(m_Makefile->GetDefinition("CMAKE_EDIT_COMMAND")) { fout << "CMAKE_EDIT_COMMAND = " - << cmSystemTools::ConvertToOutputPath(m_Makefile->GetDefinition("CMAKE_EDIT_COMMAND")) + << this->ConvertToOutputForExisting(m_Makefile->GetDefinition("CMAKE_EDIT_COMMAND")) << "\n"; } fout << "CMAKE_CURRENT_SOURCE = " << - cmSystemTools::ConvertToOutputPath(m_Makefile->GetStartDirectory()) << "\n"; + cmSystemTools::ConvertToOutputPath(m_Makefile->GetStartDirectory()) + << "\n"; fout << "CMAKE_CURRENT_BINARY = " << - cmSystemTools::ConvertToOutputPath(m_Makefile->GetStartOutputDirectory()) << "\n"; + cmSystemTools::ConvertToOutputPath(m_Makefile->GetStartOutputDirectory()) + << "\n"; fout << "CMAKE_SOURCE_DIR = " << - cmSystemTools::ConvertToOutputPath(m_Makefile->GetHomeDirectory()) << "\n"; + cmSystemTools::ConvertToOutputPath(m_Makefile->GetHomeDirectory()) + << "\n"; fout << "CMAKE_BINARY_DIR = " << - cmSystemTools::ConvertToOutputPath(m_Makefile->GetHomeOutputDirectory()) << "\n"; + cmSystemTools::ConvertToOutputPath(m_Makefile->GetHomeOutputDirectory()) + << "\n"; // Output Include paths fout << "INCLUDE_FLAGS = "; std::vector& includes = m_Makefile->GetIncludeDirectories(); @@ -1740,12 +1927,12 @@ void cmLocalUnixMakefileGenerator::OutputInstallRules(std::ostream& fout) void cmLocalUnixMakefileGenerator::OutputMakeRules(std::ostream& fout) { this->OutputMakeRule(fout, - "Default build rule", + "default build rule", "all", "cmake.depends $(TARGETS) $(SUBDIR_BUILD)", 0); this->OutputMakeRule(fout, - "remove generated files", + "clean generated files", "clean", "$(SUBDIR_CLEAN)", "-@ $(RM) $(CLEAN_OBJECT_FILES) " @@ -1771,7 +1958,7 @@ void cmLocalUnixMakefileGenerator::OutputMakeRules(std::ostream& fout) } this->OutputMakeRule(fout, - "Rule to build the cmake.depends and Makefile as side effect, if a source cmakelist file is out of date.", + "dependencies.", "cmake.depends", "$(CMAKE_MAKEFILE_SOURCES)", "$(CMAKE_COMMAND) " @@ -1779,7 +1966,7 @@ void cmLocalUnixMakefileGenerator::OutputMakeRules(std::ostream& fout) "-H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)" ); this->OutputMakeRule(fout, - "Rule to build the cmake.check_depends and Makefile as side effect, if any source file has changed.", + "dependencies", "cmake.check_depends", allsources.c_str(), "$(CMAKE_COMMAND) " @@ -1788,15 +1975,14 @@ void cmLocalUnixMakefileGenerator::OutputMakeRules(std::ostream& fout) ); this->OutputMakeRule(fout, - "Rule to force the build of cmake.depends", + "dependencies", "depend", "$(SUBDIR_DEPEND)", "$(CMAKE_COMMAND) " "-S$(CMAKE_CURRENT_SOURCE) -O$(CMAKE_CURRENT_BINARY) " "-H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)"); this->OutputMakeRule(fout, - "Rule to force the build of cmake.depends " - "in the current directory only.", + "dependencies", "dependlocal", 0, "$(CMAKE_COMMAND) " @@ -1804,7 +1990,7 @@ void cmLocalUnixMakefileGenerator::OutputMakeRules(std::ostream& fout) "-H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)"); this->OutputMakeRule(fout, - "Rebuild CMakeCache.txt file", + "CMakeCache.txt", "rebuild_cache", "$(CMAKE_BINARY_DIR)/CMakeCache.txt", "$(CMAKE_COMMAND) " @@ -1814,7 +2000,7 @@ void cmLocalUnixMakefileGenerator::OutputMakeRules(std::ostream& fout) if(m_Makefile->GetDefinition("CMAKE_EDIT_COMMAND")) { this->OutputMakeRule(fout, - "Edit the CMakeCache.txt file with ccmake or CMakeSetup", + "edit CMakeCache.txt", "edit_cache", 0, "$(CMAKE_EDIT_COMMAND) " @@ -1822,7 +2008,7 @@ void cmLocalUnixMakefileGenerator::OutputMakeRules(std::ostream& fout) } this->OutputMakeRule(fout, - "Create CMakeCache.txt file", + "CMakeCache.txt", "$(CMAKE_BINARY_DIR)/CMakeCache.txt", 0, "$(CMAKE_COMMAND) " @@ -1861,10 +2047,10 @@ void cmLocalUnixMakefileGenerator::OutputMakeRules(std::ostream& fout) if (cmSystemTools::FileExists(ctest.c_str())) { this->OutputMakeRule(fout, - "run any tests", + "tests", "test", "", - cmSystemTools::ConvertToOutputPath(ctest.c_str()).c_str()); + this->ConvertToOutputForExisting(ctest.c_str()).c_str()); } } @@ -1882,55 +2068,120 @@ OutputBuildObjectFromSource(std::ostream& fout, return; } - std::string comment = "Build "; - std::string objectFile = std::string(shortName) + m_ObjectFileExtension; + std::string comment = "object file"; + std::string objectFile = std::string(shortName) + + this->GetOutputExtension(source.GetSourceExtension().c_str()); objectFile = cmSystemTools::ConvertToOutputPath(objectFile.c_str()); - comment += objectFile + " From "; - comment += source.GetFullPath(); std::string compileCommand; - cmSystemTools::e_FileFormat format = + cmSystemTools::FileFormat format = cmSystemTools::GetFileFormat(source.GetSourceExtension().c_str()); - if( format == cmSystemTools::C_FILE_FORMAT ) + std::vector rules; + std::string flags; + if(extraCompileFlags) { - compileCommand = "$(CMAKE_C_COMPILER) $(CMAKE_C_FLAGS) "; - compileCommand += extraCompileFlags; - if(shared) - { - compileCommand += "$(CMAKE_SHLIB_CFLAGS) "; - } - compileCommand += "$(INCLUDE_FLAGS) -c "; - compileCommand += - cmSystemTools::ConvertToOutputPath(source.GetFullPath().c_str()); - compileCommand += " -o "; - compileCommand += objectFile; + flags += extraCompileFlags; } - else if ( format == cmSystemTools::CXX_FILE_FORMAT ) + flags += "$(INCLUDE_FLAGS) "; + std::string sourceFile = + cmSystemTools::ConvertToOutputPath(source.GetFullPath().c_str()); + std::string buildType = this->GetSafeDefinition("CMAKE_BUILD_TYPE"); + buildType = cmSystemTools::UpperCase(buildType); + switch(format) { - compileCommand = "$(CMAKE_CXX_COMPILER) $(CMAKE_CXX_FLAGS) "; - compileCommand += extraCompileFlags; - if(shared) + case cmSystemTools::C_FILE_FORMAT: { - compileCommand += "$(CMAKE_SHLIB_CFLAGS) "; + rules.push_back(m_Makefile->GetDefinition("CMAKE_C_COMPILE_OBJECT")); + flags += this->GetSafeDefinition("CMAKE_C_FLAGS"); + flags += " "; + if(shared) + { + flags += this->GetSafeDefinition("CMAKE_SHARED_LIBRARY_C_FLAGS"); + flags += this->GetSafeDefinition("CMAKE_C_FLAGS"); + flags += " "; + if(buildType.size()) + { + std::string build = "CMAKE_C_FLAGS_"; + build += buildType; + flags += this->GetSafeDefinition(build.c_str()); + flags += " "; + } + } + break; } - compileCommand += "$(INCLUDE_FLAGS) -c "; - compileCommand += - cmSystemTools::ConvertToOutputPath(source.GetFullPath().c_str()); - compileCommand += " -o "; - compileCommand += objectFile; + case cmSystemTools::CXX_FILE_FORMAT: + { + rules.push_back(m_Makefile->GetDefinition("CMAKE_CXX_COMPILE_OBJECT")); + flags += this->GetSafeDefinition("CMAKE_CXX_FLAGS"); + flags += " "; + if(buildType.size()) + { + std::string build = "CMAKE_CXX_FLAGS_"; + build += buildType; + flags += this->GetSafeDefinition(build.c_str()); + flags += " "; + } + if(shared) + { + flags += this->GetSafeDefinition("CMAKE_SHARED_LIBRARY_CXX_FLAGS"); + flags += " "; + } + break; + } + case cmSystemTools::HEADER_FILE_FORMAT: + return; + break; + case cmSystemTools::DEFINITION_FILE_FORMAT: + return; + break; + case cmSystemTools::RESOURCE_FILE_FORMAT: + { + flags = " $(INCLUDE_FLAGS) "; + // use rc rule here if it is defined + const char* rule = m_Makefile->GetDefinition("CMAKE_COMPILE_RESOURCE"); + if(rule) + { + rules.push_back(rule); + } + } + break; + case cmSystemTools::NO_FILE_FORMAT: + case cmSystemTools::JAVA_FILE_FORMAT: + case cmSystemTools::STATIC_LIBRARY_FILE_FORMAT: + case cmSystemTools::SHARED_LIBRARY_FILE_FORMAT: + case cmSystemTools::MODULE_FILE_FORMAT: + case cmSystemTools::OBJECT_FILE_FORMAT: + case cmSystemTools::UNKNOWN_FILE_FORMAT: + cmSystemTools::Error("Unexpected file type ", + sourceFile.c_str()); + break; + } + // expand multi-command semi-colon separated lists + // of commands into separate commands + std::vector commands; + cmSystemTools::ExpandListArguments(rules, commands); + for(std::vector::iterator i = commands.begin(); + i != commands.end(); ++i) + { + this->ExpandRuleVariables(*i, + 0, // no objects + 0, // no target + 0, // no link libs + sourceFile.c_str(), + objectFile.c_str(), + flags.c_str() ); } this->OutputMakeRule(fout, comment.c_str(), objectFile.c_str(), - cmSystemTools::ConvertToOutputPath(source.GetFullPath(). - c_str()).c_str(), - compileCommand.c_str()); + sourceFile.c_str(), + commands); } void cmLocalUnixMakefileGenerator::OutputSourceObjectBuildRules(std::ostream& fout) { - fout << "# Rules to build " << m_ObjectFileExtension + fout << "# Rules to build " << this->GetOutputExtension("") << " files from their sources:\n"; std::set rules; @@ -2006,14 +2257,42 @@ void cmLocalUnixMakefileGenerator::OutputSourceObjectBuildRules(std::ostream& fo } } + void cmLocalUnixMakefileGenerator::OutputMakeRule(std::ostream& fout, - const char* comment, - const char* target, - const char* depends, - const char* command, - const char* command2, - const char* command3, - const char* command4) + const char* comment, + const char* target, + const char* depends, + const char* command, + const char* command2, + const char* command3, + const char* command4) +{ + std::vector commands; + if(command) + { + commands.push_back(command); + } + if(command2) + { + commands.push_back(command2); + } + if(command3) + { + commands.push_back(command3); + } + if(command4) + { + commands.push_back(command4); + } + this->OutputMakeRule(fout, comment, target, depends, commands); +} + + +void cmLocalUnixMakefileGenerator::OutputMakeRule(std::ostream& fout, + const char* comment, + const char* target, + const char* depends, + const std::vector& commands) { if(!target) { @@ -2043,37 +2322,115 @@ void cmLocalUnixMakefileGenerator::OutputMakeRule(std::ostream& fout, fout << replace.c_str(); } fout << "\n"; - - const char* commands[] = { command, command2, command3, command4 }; - - for (unsigned int i = 0; i < sizeof(commands) / sizeof(commands[0]); ++i) + int count = 0; + for (std::vector::const_iterator i = commands.begin(); + i != commands.end(); ++i) { - if(commands[i]) + replace = *i; + m_Makefile->ExpandVariablesInString(replace); + if(count == 0 && replace[0] != '-' && replace.find("echo") != 0 + && replace.find("$(MAKE)") != 0) { - replace = commands[i]; - m_Makefile->ExpandVariablesInString(replace); - if(replace[0] != '-' && replace.find("echo") != 0 - && replace.find("$(MAKE)") != 0) + std::string echostring = "Building "; + echostring += comment; + echostring += " "; + echostring += target; + echostring += "..."; + + // for unix we want to quote the output of echo + // for nmake and borland, the echo should not be quoted + if(strcmp(m_GlobalGenerator->GetName(), "Unix Makefiles") == 0) { - std::string echostring = replace; - // for unix we want to quote the output of echo - // for nmake and borland, the echo should not be quoted - if(strcmp(m_GlobalGenerator->GetName(), "Unix Makefiles") == 0) - { - cmSystemTools::ReplaceString(echostring, "\\\n", " "); - cmSystemTools::ReplaceString(echostring, " \t", " "); - cmSystemTools::ReplaceString(echostring, "\n\t", "\"\n\techo \""); - fout << "\techo \"" << echostring.c_str() << "\"\n"; - } - else - { - cmSystemTools::ReplaceString(echostring, "\n\t", "\n\techo "); - fout << "\techo " << echostring.c_str() << "\n"; - } + cmSystemTools::ReplaceString(echostring, "\\\n", " "); + cmSystemTools::ReplaceString(echostring, " \t", " "); + cmSystemTools::ReplaceString(echostring, "\n\t", "\"\n\techo \""); + fout << "\techo \"" << echostring.c_str() << "\"\n"; + } + else + { + cmSystemTools::ReplaceString(echostring, "\n\t", "\n\techo "); + fout << "\techo " << echostring.c_str() << "\n"; } - fout << "\t" << replace.c_str() << "\n"; } + fout << "\t" << replace.c_str() << "\n"; + count++; } fout << "\n"; } +const char* cmLocalUnixMakefileGenerator::GetSafeDefinition(const char* def) +{ + const char* ret = m_Makefile->GetDefinition(def); + if(!ret) + { + return ""; + } + return ret; +} + +std::string cmLocalUnixMakefileGenerator::LowerCasePath(const char* path) +{ +#ifdef _WIN32 + return cmSystemTools::LowerCase(path); +#else + return std::string(path); +#endif +} + +std::string +cmLocalUnixMakefileGenerator::CreateMakeVariable(const char* s, const char* s2) +{ + if(!m_MakefileVariableSize) + { + return std::string(s) + std::string(s2); + } + std::string unmodified = s; + unmodified += s2; + // see if th + std::map::iterator i = m_MakeVariableMap.find(unmodified); + if(i != m_MakeVariableMap.end()) + { + return i->second; + } + std::string ret = unmodified; + // if the string is greater the 32 chars it is an invalid vairable name + // for borland make + if(ret.size() > m_MakefileVariableSize) + { + int keep = m_MakefileVariableSize - 8; + int size = keep + 3; + std::string str1 = s; + std::string str2 = s2; + // we must shorten the combined string by 4 charactors + // keep no more than 24 charactors from the second string + if(str2.size() > keep) + { + str2 = str2.substr(0, keep); + } + if(str1.size() + str2.size() > size) + { + str1 = str1.substr(0, size - str2.size()); + } + char buffer[5]; + int i = 0; + sprintf(buffer, "%04d", i); + ret = str1 + str2 + buffer; + while(m_ShortMakeVariableMap.count(ret) && i < 1000) + { + ++i; + sprintf(buffer, "%04d", i); + ret = str1 + str2 + buffer; + } + if(i == 1000) + { + cmSystemTools::Error("Borland makefile varible length too long"); + return unmodified; + } + // once an unused variable is found + m_ShortMakeVariableMap[ret] = "1"; + } + // always make an entry into the unmodified to varible map + m_MakeVariableMap[unmodified] = ret; + return ret; + +} diff --git a/Source/cmLocalUnixMakefileGenerator.h b/Source/cmLocalUnixMakefileGenerator.h index 47fbafd64..c441ace1a 100644 --- a/Source/cmLocalUnixMakefileGenerator.h +++ b/Source/cmLocalUnixMakefileGenerator.h @@ -60,12 +60,45 @@ public: */ virtual void OutputCheckDepends(std::ostream&); + /** + * Set to true if the shell being used is the windows shell. + * This controls if statements in the makefile and the SHELL variable. + * The default is false. + */ + void SetWindowsShell(bool v) {m_WindowsShell = v;} + + ///! Set the string used to include one makefile into another default is include. + void SetIncludeDirective(const char* s) { m_IncludeDirective = s; } + + ///! Set the flag used to keep the make program silent. + void SetMakeSilentFlag(const char* s) { m_MakeSilentFlag = s; } + + ///! Set max makefile variable size, default is 0 which means unlimited. + void SetMakefileVariableSize(int s) { m_MakefileVariableSize = s; } + protected: + virtual const char* GetSafeDefinition(const char*); virtual void ProcessDepends(const cmMakeDepend &md); virtual void OutputMakefile(const char* file, bool withDepends); virtual void OutputTargetRules(std::ostream& fout); virtual void OutputLinkLibraries(std::ostream&, const char* name, const cmTarget &); - + void OutputLibraryRule(std::ostream& fout, + const char* name, + const cmTarget &t, + const char* prefix, + const char* suffix, + const char* createRule, + const char* comment + ); + void ExpandRuleVariables(std::string& string, + const char* objects=0, + const char* target=0, + const char* linkLibs=0, + const char* source=0, + const char* object =0, + const char* flags = 0, + const char* objectsquoted = 0, + const char* targetBase = 0); virtual void OutputSharedLibraryRule(std::ostream&, const char* name, const cmTarget &); virtual void OutputModuleLibraryRule(std::ostream&, const char* name, @@ -99,6 +132,12 @@ protected: const char* target2, bool silent = false); + virtual void BuildInSubDirectoryWindows(std::ostream& fout, + const char* directory, + const char* target1, + const char* target2, + bool silent = false); + virtual void OutputSubDirectoryVars(std::ostream& fout, const char* var, const char* target, @@ -109,6 +148,12 @@ protected: SubDirectories, bool silent = false); + virtual void OutputMakeRule(std::ostream&, + const char* comment, + const char* target, + const char* depends, + const std::vector& commands); + virtual void OutputMakeRule(std::ostream&, const char* comment, const char* target, @@ -125,33 +170,25 @@ protected: ///! return true if the two paths are the same virtual bool SamePath(const char* path1, const char* path2); virtual std::string GetOutputExtension(const char* sourceExtension); - virtual void OutputIncludeMakefile(std::ostream&, const char* file); - void SetObjectFileExtension(const char* e) { m_ObjectFileExtension = e;} - void SetExecutableExtension(const char* e) { m_ExecutableExtension = e;} - void SetStaticLibraryExtension(const char* e) {m_StaticLibraryExtension = e;} - void SetSharedLibraryExtension(const char* e) {m_SharedLibraryExtension = e;} - void SetLibraryPrefix(const char* e) { m_LibraryPrefix = e;} std::string CreateTargetRules(const cmTarget &target, const char* targetName); - virtual std::string CreateMakeVariable(const char* s, const char* s2) - { - return std::string(s) + std::string(s2); - } + virtual std::string CreateMakeVariable(const char* s, const char* s2); ///! if the OS is case insensitive then return a lower case of the path. - virtual std::string LowerCasePath(const char* path) - { - return std::string(path); - } - + virtual std::string LowerCasePath(const char* path); + + ///! for existing files convert to output path and short path if spaces + std::string ConvertToOutputForExisting(const char*); protected: + int m_MakefileVariableSize; + std::map m_MakeVariableMap; + std::map m_ShortMakeVariableMap; + + std::string m_IncludeDirective; + std::string m_MakeSilentFlag; std::string m_ExecutableOutputPath; std::string m_LibraryOutputPath; - std::string m_SharedLibraryExtension; - std::string m_ObjectFileExtension; - std::string m_ExecutableExtension; - std::string m_StaticLibraryExtension; - std::string m_LibraryPrefix; + bool m_WindowsShell; private: }; diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 2e97a83fc..bc8bf6bdc 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1403,8 +1403,7 @@ int cmMakefile::TryCompile(const char *srcdir, const char *bindir, cm.SetCacheArgs(*cmakeArgs); } // to save time we pass the EnableLanguage info directly - gg->EnableLanguagesFromGenerator(m_LocalGenerator->GetGlobalGenerator(), - this); + gg->EnableLanguagesFromGenerator(m_LocalGenerator->GetGlobalGenerator()); if (cm.Configure() != 0) { diff --git a/Source/cmStandardIncludes.h b/Source/cmStandardIncludes.h index d514ecf3b..ceab7fccc 100644 --- a/Source/cmStandardIncludes.h +++ b/Source/cmStandardIncludes.h @@ -219,9 +219,9 @@ class cmIStringStream: private std::string, public std::istrstream public: typedef std::string StdString; typedef std::istrstream IStrStream; - cmIStringStream(): StdString(), IStrStream(this->StdString::c_str()) {} + cmIStringStream(): StdString(), IStrStream(StdString::c_str()) {} cmIStringStream(const std::string& s): - StdString(s), IStrStream(this->StdString::c_str()) {} + StdString(s), IStrStream(StdString::c_str()) {} std::string str() const { return *this; } void str(const std::string& s) { diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 3a6c36294..bec0575bd 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -124,7 +124,7 @@ cmSystemTools::GetTime(void) #endif /* !HAVE_FTIME */ } } - +bool cmSystemTools::s_RunCommandHideConsole = false; bool cmSystemTools::s_DisableRunCommandOutput = false; bool cmSystemTools::s_ErrorOccured = false; bool cmSystemTools::s_DisableMessages = false; @@ -251,10 +251,15 @@ void cmSystemTools::ReplaceString(std::string& source, const char* replace, const char* with) { + // get out quick if string is not found + std::string::size_type start = source.find(replace); + if(start == std::string::npos) + { + return; + } + std::string rest; std::string::size_type lengthReplace = strlen(replace); std::string::size_type lengthWith = strlen(with); - std::string rest; - std::string::size_type start = source.find(replace); while(start != std::string::npos) { rest = source.substr(start+lengthReplace); @@ -1330,7 +1335,8 @@ bool RunCommandViaWin32(const char* command, #if defined(__BORLANDC__) return cmWin32ProcessExecution::BorlandRunCommand(command, dir, output, retVal, - verbose, timeout); + verbose, timeout, + cmSystemTools::GetRunCommandHideConsole()); #else // Visual studio ::SetLastError(ERROR_SUCCESS); if ( ! command ) @@ -1338,13 +1344,13 @@ bool RunCommandViaWin32(const char* command, cmSystemTools::Error("No command specified"); return false; } - //std::cout << "Command: " << command << std::endl; - if ( dir ) - { - //std::cout << "Dir: " << dir << std::endl; - } cmWin32ProcessExecution resProc; + if(cmSystemTools::GetRunCommandHideConsole()) + { + resProc.SetHideWindows(true); + } + if ( cmSystemTools::GetWindows9xComspecSubstitute() ) { resProc.SetConsoleSpawn(cmSystemTools::GetWindows9xComspecSubstitute() ); @@ -2367,7 +2373,7 @@ bool cmSystemTools::SimpleGlob(const std::string& glob, return res; } -cmSystemTools::e_FileFormat cmSystemTools::GetFileFormat(const char* cext) +cmSystemTools::FileFormat cmSystemTools::GetFileFormat(const char* cext) { if ( ! cext || *cext == 0 ) { diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index 5218fa9e1..8d915ca5b 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -321,7 +321,7 @@ public: /** * Come constants for different file formats. */ - enum e_FileFormat { + enum FileFormat { NO_FILE_FORMAT = 0, C_FILE_FORMAT, CXX_FILE_FORMAT, @@ -339,7 +339,7 @@ public: /** * Determine the file type based on the extension */ - static e_FileFormat GetFileFormat(const char* ext); + static FileFormat GetFileFormat(const char* ext); /** * On Windows 9x we need a comspec (command.com) substitute to run @@ -349,6 +349,11 @@ public: static void SetWindows9xComspecSubstitute(const char*); static const char* GetWindows9xComspecSubstitute(); + /** Windows if this is true, the CreateProcess in RunCommand will + * not show new consol windows when running programs. + */ + static void SetRunCommandHideConsole(bool v){s_RunCommandHideConsole = v;} + static bool GetRunCommandHideConsole(){ return s_RunCommandHideConsole;} protected: // these two functions can be called from ConvertToOutputPath /** @@ -366,6 +371,7 @@ protected: static std::string ConvertToWindowsOutputPath(const char*); private: + static bool s_RunCommandHideConsole; static bool s_ErrorOccured; static bool s_DisableMessages; static bool s_DisableRunCommandOutput; diff --git a/Source/cmTryCompileCommand.cxx b/Source/cmTryCompileCommand.cxx index f56829a37..b18718252 100644 --- a/Source/cmTryCompileCommand.cxx +++ b/Source/cmTryCompileCommand.cxx @@ -135,7 +135,7 @@ int cmTryCompileCommand::CoreTryCompileCode( } std::string source = argv[2]; - cmSystemTools::e_FileFormat format = + cmSystemTools::FileFormat format = cmSystemTools::GetFileFormat( cmSystemTools::GetFilenameExtension(source).c_str()); if ( format == cmSystemTools::C_FILE_FORMAT ) diff --git a/Source/cmWin32ProcessExecution.cxx b/Source/cmWin32ProcessExecution.cxx index e56f0f337..9c387818f 100644 --- a/Source/cmWin32ProcessExecution.cxx +++ b/Source/cmWin32ProcessExecution.cxx @@ -110,7 +110,7 @@ inline bool IsWinNT() //--------------------------------------------------------------------------- bool cmWin32ProcessExecution::BorlandRunCommand( const char* command, const char* dir, - std::string& output, int& retVal, bool verbose, int /* timeout */) + std::string& output, int& retVal, bool verbose, int /* timeout */, bool hideWindows) { //verbose = true; //std::cerr << std::endl @@ -170,7 +170,11 @@ bool cmWin32ProcessExecution::BorlandRunCommand( si.dwFlags = STARTF_USESTDHANDLES|STARTF_USESHOWWINDOW; si.hStdOutput = newstdout; si.hStdError = newstdout; - si.wShowWindow = SW_SHOWDEFAULT; // SW_HIDE; + si.wShowWindow = SW_SHOWDEFAULT; + if(hideWindows) + { + si.wShowWindow = SW_HIDE; + } //set the new handles for the child process si.hStdInput = newstdin; char* commandAndArgs = strcpy(new char[strlen(command)+1], command); @@ -285,7 +289,8 @@ static BOOL RealPopenCreateProcess(const char *cmdstring, HANDLE hStdin, HANDLE hStdout, HANDLE hStderr, - HANDLE *hProcess) + HANDLE *hProcess, + bool hideWindows) { PROCESS_INFORMATION piProcInfo; STARTUPINFO siStartInfo; @@ -404,7 +409,11 @@ static BOOL RealPopenCreateProcess(const char *cmdstring, siStartInfo.hStdInput = hStdin; siStartInfo.hStdOutput = hStdout; siStartInfo.hStdError = hStderr; - siStartInfo.wShowWindow = SW_SHOWDEFAULT; // SW_HIDE; + siStartInfo.wShowWindow = SW_SHOWDEFAULT; + if(hideWindows) + { + siStartInfo.wShowWindow = SW_HIDE; + } //std::cout << "Create process: " << s2 << std::endl; if (CreateProcess(NULL, @@ -617,7 +626,7 @@ bool cmWin32ProcessExecution::PrivateOpen(const char *cmdstring, hChildStdinRd, hChildStdoutWr, hChildStdoutWr, - &hProcess)) + &hProcess, m_HideWindows)) return NULL; } else @@ -628,7 +637,7 @@ bool cmWin32ProcessExecution::PrivateOpen(const char *cmdstring, hChildStdinRd, hChildStdoutWr, hChildStderrWr, - &hProcess)) + &hProcess, m_HideWindows)) return NULL; } diff --git a/Source/cmWin32ProcessExecution.h b/Source/cmWin32ProcessExecution.h index 6dec659d1..ea387684d 100644 --- a/Source/cmWin32ProcessExecution.h +++ b/Source/cmWin32ProcessExecution.h @@ -45,10 +45,13 @@ class cmWin32ProcessExecution public: cmWin32ProcessExecution() { + m_HideWindows = false; this->SetConsoleSpawn("w9xpopen.exe"); this->Initialize(); } - + ///! If true windows will be created hidden. + void SetHideWindows(bool v) { m_HideWindows = v; } + /** * Initialize the process execution datastructure. Do not call while * running the process. @@ -133,7 +136,7 @@ public: */ static bool BorlandRunCommand(const char* command, const char* dir, std::string& output, int& retVal, bool verbose, - int timeout); + int timeout, bool hideWindows); private: bool PrivateOpen(const char*, const char*, int, int); @@ -156,6 +159,7 @@ private: std::string m_Output; std::string m_ConsoleSpawn; bool m_Verbose; + bool m_HideWindows; }; diff --git a/Source/ctest.cxx b/Source/ctest.cxx index d17ce2ce6..5f4dd6b15 100644 --- a/Source/ctest.cxx +++ b/Source/ctest.cxx @@ -195,6 +195,10 @@ void ctest::Initialize() fin.getline(buffer, 1023); buffer[1023] = 0; std::string line = ::CleanString(buffer); + if(line.size() == 0) + { + continue; + } while ( fin && (line[line.size()-1] == '\\') ) { line = line.substr(0, line.size()-1); @@ -207,10 +211,6 @@ void ctest::Initialize() { continue; } - if ( line.size() == 0 ) - { - continue; - } std::string::size_type cpos = line.find_first_of(":"); if ( cpos == line.npos ) {