ENH: major changes to support addition of languages from cmake modules directory.

This commit is contained in:
Bill Hoffman 2004-09-22 14:42:05 -04:00
parent 5971857544
commit 692ba48c4e
55 changed files with 975 additions and 605 deletions

View File

@ -15,3 +15,11 @@ IF(CMAKE_COMPILER_IS_MINGW)
ENDIF(CMAKE_COMPILER_IS_MINGW)
SET(CMAKE_COMPILER_IS_GNUCC_RUN 1)
SET(CMAKE_C_SOURCE_FILE_EXTENSIONS c)
SET(CMAKE_C_IGNORE_EXTENSIONS h;H;o;O;obj;OBJ;def;DEF;rc;RC)
SET(CMAKE_C_LINKER_PREFERENCE None)
IF(UNIX)
SET(CMAKE_C_OUTPUT_EXTENSION .o)
ELSE(UNIX)
SET(CMAKE_C_OUTPUT_EXTENSION .obj)
ENDIF(UNIX)

View File

@ -21,9 +21,6 @@ ENDIF(NOT CMAKE_MODULE_EXISTS)
SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS_ENV_INIT} $ENV{CFLAGS} ${CMAKE_C_FLAGS_INIT}" CACHE STRING
"Flags for C compiler.")
SET (CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS_INIT} $ENV{LDFLAGS}
CACHE STRING "Flags used by the linker.")
IF(NOT CMAKE_NOT_USING_CONFIG_FLAGS)
# default build type is none
IF(NOT CMAKE_NO_BUILD_TYPE)

View File

@ -2,5 +2,11 @@ SET(CMAKE_CXX_COMPILER "@CMAKE_CXX_COMPILER@")
SET(CMAKE_COMPILER_IS_GNUCXX @CMAKE_COMPILER_IS_GNUCXX@)
SET(CMAKE_CXX_COMPILER_LOADED 1)
SET(CMAKE_COMPILER_IS_GNUCC_RUN 1)
SET(CMAKE_CXX_IGNORE_EXTENSIONS h;H;o;O;obj;OBJ;def;DEF;rc;RC)
SET(CMAKE_CXX_SOURCE_FILE_EXTENSIONS C;M;c++;cc;cpp;cxx;m;mm)
SET(CMAKE_CXX_LINKER_PREFERENCE Prefered)
IF(UNIX)
SET(CMAKE_CXX_OUTPUT_EXTENSION .o)
ELSE(UNIX)
SET(CMAKE_CXX_OUTPUT_EXTENSION .obj)
ENDIF(UNIX)

View File

@ -30,17 +30,25 @@ IF(NOT CMAKE_SHARED_LIBRARY_CXX_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})
SET(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS ${CMAKE_SHARED_LIBRARY_LINK_C_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})
SET(CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG ${CMAKE_SHARED_LIBRARY_RUNTIME_C_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})
SET(CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG_SEP ${CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP})
ENDIF(NOT CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG_SEP)
IF(NOT CMAKE_INCLUDE_FLAG_CXX)
SET(CMAKE_INCLUDE_FLAG_CXX ${CMAKE_INCLUDE_FLAG_C})
ENDIF(NOT CMAKE_INCLUDE_FLAG_CXX)
IF(NOT CMAKE_INCLUDE_FLAG_SEP_CXX)
SET(CMAKE_INCLUDE_FLAG_SEP_CXX ${CMAKE_INCLUDE_FLAG_SEP_C})
ENDIF(NOT CMAKE_INCLUDE_FLAG_SEP_CXX)
# repeat for modules
IF(NOT CMAKE_SHARED_MODULE_CREATE_CXX_FLAGS)
SET(CMAKE_SHARED_MODULE_CREATE_CXX_FLAGS ${CMAKE_SHARED_MODULE_CREATE_C_FLAGS})

View File

@ -2,6 +2,10 @@
# cache values that can be initialized in the platform-compiler.cmake file
# it may be included by more than one language.
SET (CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS_INIT} $ENV{LDFLAGS}
CACHE STRING "Flags used by the linker.")
IF(NOT CMAKE_NOT_USING_CONFIG_FLAGS)
# default build type is none
IF(NOT CMAKE_NO_BUILD_TYPE)

View File

@ -1,34 +1,40 @@
# determine the compiler to use for Java programs
# NOTE, a generator may set CMAKE_JAVA_COMPILER before
# NOTE, a generator may set CMAKE_Java_COMPILER before
# loading this file to force a compiler.
IF(NOT CMAKE_JAVA_COMPILER)
IF(NOT CMAKE_Java_COMPILER)
# prefer the environment variable CC
IF($ENV{JAVA_COMPILER} MATCHES ".+")
GET_FILENAME_COMPONENT(CMAKE_JAVA_COMPILER_INIT $ENV{JAVA_COMPILER} PROGRAM PROGRAM_ARGS CMAKE_JAVA_FLAGS_ENV_INIT)
IF(EXISTS ${CMAKE_JAVA_COMPILER_INIT})
ELSE(EXISTS ${CMAKE_JAVA_COMPILER_INIT})
GET_FILENAME_COMPONENT(CMAKE_Java_COMPILER_INIT $ENV{JAVA_COMPILER} PROGRAM PROGRAM_ARGS CMAKE_Java_FLAGS_ENV_INIT)
IF(EXISTS ${CMAKE_Java_COMPILER_INIT})
ELSE(EXISTS ${CMAKE_Java_COMPILER_INIT})
MESSAGE(SEND_ERROR "Could not find compiler set in environment variable JAVA_COMPILER:\n$ENV{JAVA_COMPILER}.")
ENDIF(EXISTS ${CMAKE_JAVA_COMPILER_INIT})
ENDIF(EXISTS ${CMAKE_Java_COMPILER_INIT})
ENDIF($ENV{JAVA_COMPILER} MATCHES ".+")
IF($ENV{JAVA_RUNTIME} MATCHES ".+")
GET_FILENAME_COMPONENT(CMAKE_JAVA_RUNTIME_INIT $ENV{JAVA_RUNTIME} PROGRAM PROGRAM_ARGS CMAKE_JAVA_FLAGS_ENV_INIT)
IF(EXISTS ${CMAKE_JAVA_RUNTIME_INIT})
ELSE(EXISTS ${CMAKE_JAVA_RUNTIME_INIT})
GET_FILENAME_COMPONENT(CMAKE_Java_RUNTIME_INIT $ENV{JAVA_RUNTIME} PROGRAM PROGRAM_ARGS CMAKE_Java_FLAGS_ENV_INIT)
IF(EXISTS ${CMAKE_Java_RUNTIME_INIT})
ELSE(EXISTS ${CMAKE_Java_RUNTIME_INIT})
MESSAGE(SEND_ERROR "Could not find compiler set in environment variable JAVA_RUNTIME:\n$ENV{JAVA_RUNTIME}.")
ENDIF(EXISTS ${CMAKE_JAVA_RUNTIME_INIT})
ENDIF(EXISTS ${CMAKE_Java_RUNTIME_INIT})
ENDIF($ENV{JAVA_RUNTIME} MATCHES ".+")
IF($ENV{JAVA_ARCHIVE} MATCHES ".+")
GET_FILENAME_COMPONENT(CMAKE_JAVA_ARCHIVE_INIT $ENV{JAVA_ARCHIVE} PROGRAM PROGRAM_ARGS CMAKE_JAVA_FLAGS_ENV_INIT)
IF(EXISTS ${CMAKE_JAVA_ARCHIVE_INIT})
ELSE(EXISTS ${CMAKE_JAVA_ARCHIVE_INIT})
GET_FILENAME_COMPONENT(CMAKE_Java_ARCHIVE_INIT $ENV{JAVA_ARCHIVE} PROGRAM PROGRAM_ARGS CMAKE_Java_FLAGS_ENV_INIT)
IF(EXISTS ${CMAKE_Java_ARCHIVE_INIT})
ELSE(EXISTS ${CMAKE_Java_ARCHIVE_INIT})
MESSAGE(SEND_ERROR "Could not find compiler set in environment variable JAVA_ARCHIVE:\n$ENV{JAVA_ARCHIVE}.")
ENDIF(EXISTS ${CMAKE_JAVA_ARCHIVE_INIT})
ENDIF(EXISTS ${CMAKE_Java_ARCHIVE_INIT})
ENDIF($ENV{JAVA_ARCHIVE} MATCHES ".+")
SET(JAVA_BIN_PATH
SET(Java_BIN_PATH
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\2.0;JavaHome]/bin"
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.9;JavaHome]/bin"
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.8;JavaHome]/bin"
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.7;JavaHome]/bin"
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.6;JavaHome]/bin"
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.5;JavaHome]/bin"
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.4;JavaHome]/bin"
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.3;JavaHome]/bin"
/usr/bin
@ -36,41 +42,42 @@ IF(NOT CMAKE_JAVA_COMPILER)
/usr/share/java/bin
/usr/local/bin
/usr/local/java/bin
/usr/java/j2sdk1.4.2_04
)
# if no compiler has been specified yet, then look for one
IF(CMAKE_JAVA_COMPILER_INIT)
SET(CMAKE_JAVA_COMPILER ${CMAKE_JAVA_COMPILER_INIT} CACHE PATH "Java Compiler")
ELSE(CMAKE_JAVA_COMPILER_INIT)
FIND_PROGRAM(CMAKE_JAVA_COMPILER
IF(CMAKE_Java_COMPILER_INIT)
SET(CMAKE_Java_COMPILER ${CMAKE_Java_COMPILER_INIT} CACHE PATH "Java Compiler")
ELSE(CMAKE_Java_COMPILER_INIT)
FIND_PROGRAM(CMAKE_Java_COMPILER
NAMES javac
PATHS ${JAVA_BIN_PATH}
PATHS ${Java_BIN_PATH}
)
ENDIF(CMAKE_JAVA_COMPILER_INIT)
ENDIF(CMAKE_Java_COMPILER_INIT)
# if no runtime has been specified yet, then look for one
IF(CMAKE_JAVA_RUNTIME_INIT)
SET(CMAKE_JAVA_RUNTIME ${CMAKE_JAVA_RUNTIME_INIT} CACHE PATH "Java Compiler")
ELSE(CMAKE_JAVA_RUNTIME_INIT)
FIND_PROGRAM(CMAKE_JAVA_RUNTIME
IF(CMAKE_Java_RUNTIME_INIT)
SET(CMAKE_Java_RUNTIME ${CMAKE_Java_RUNTIME_INIT} CACHE PATH "Java Compiler")
ELSE(CMAKE_Java_RUNTIME_INIT)
FIND_PROGRAM(CMAKE_Java_RUNTIME
NAMES java
PATHS ${JAVA_BIN_PATH}
PATHS ${Java_BIN_PATH}
)
ENDIF(CMAKE_JAVA_RUNTIME_INIT)
ENDIF(CMAKE_Java_RUNTIME_INIT)
# if no archive has been specified yet, then look for one
IF(CMAKE_JAVA_ARCHIVE_INIT)
SET(CMAKE_JAVA_ARCHIVE ${CMAKE_JAVA_ARCHIVE_INIT} CACHE PATH "Java Compiler")
ELSE(CMAKE_JAVA_ARCHIVE_INIT)
FIND_PROGRAM(CMAKE_JAVA_ARCHIVE
IF(CMAKE_Java_ARCHIVE_INIT)
SET(CMAKE_Java_ARCHIVE ${CMAKE_Java_ARCHIVE_INIT} CACHE PATH "Java Compiler")
ELSE(CMAKE_Java_ARCHIVE_INIT)
FIND_PROGRAM(CMAKE_Java_ARCHIVE
NAMES jar
PATHS ${JAVA_BIN_PATH}
PATHS ${Java_BIN_PATH}
)
ENDIF(CMAKE_JAVA_ARCHIVE_INIT)
ENDIF(NOT CMAKE_JAVA_COMPILER)
MARK_AS_ADVANCED(CMAKE_JAVA_COMPILER)
ENDIF(CMAKE_Java_ARCHIVE_INIT)
ENDIF(NOT CMAKE_Java_COMPILER)
MARK_AS_ADVANCED(CMAKE_Java_COMPILER)
# configure variables set in this file for fast reload later on
CONFIGURE_FILE(${CMAKE_ROOT}/Modules/CMakeJavaCompiler.cmake.in
${CMAKE_BINARY_DIR}/CMakeJavaCompiler.cmake IMMEDIATE @ONLY)
MARK_AS_ADVANCED(CMAKE_AR CMAKE_JAVA_COMPILER_FULLPATH)
SET(CMAKE_JAVA_COMPILER_ENV_VAR "JC")
MARK_AS_ADVANCED(CMAKE_AR CMAKE_Java_COMPILER_FULLPATH)
SET(CMAKE_Java_COMPILER_ENV_VAR "JAVA_COMPILER")

View File

@ -0,0 +1,44 @@
# 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
IF(NOT CMAKE_RC_COMPILER)
# prefer the environment variable CC
IF($ENV{RC} MATCHES ".+")
GET_FILENAME_COMPONENT(CMAKE_RC_COMPILER_INIT $ENV{RC} PROGRAM PROGRAM_ARGS CMAKE_RC_FLAGS_ENV_INIT)
IF(EXISTS ${CMAKE_RC_COMPILER_INIT})
ELSE(EXISTS ${CMAKE_RC_COMPILER_INIT})
MESSAGE(FATAL_ERROR "Could not find compiler set in environment variable RC:\n$ENV{RC}.")
ENDIF(EXISTS ${CMAKE_RC_COMPILER_INIT})
ENDIF($ENV{RC} MATCHES ".+")
# next try prefer the compiler specified by the generator
IF(CMAKE_GENERATOR_RC)
IF(NOT CMAKE_RC_COMPILER_INIT)
SET(CMAKE_RC_COMPILER_INIT ${CMAKE_GENERATOR_RC})
ENDIF(NOT CMAKE_RC_COMPILER_INIT)
ENDIF(CMAKE_GENERATOR_RC)
# if no compiler has been specified yet, then look for one
IF(NOT CMAKE_RC_COMPILER_INIT)
SET(CMAKE_RC_COMPILER_LIST rc)
FIND_PROGRAM(CMAKE_RC_COMPILER_FULLPATH NAMES ${CMAKE_RC_COMPILER_LIST} )
GET_FILENAME_COMPONENT(CMAKE_RC_COMPILER_INIT
${CMAKE_RC_COMPILER_FULLPATH} NAME)
SET(CMAKE_RC_COMPILER_FULLPATH "${CMAKE_RC_COMPILER_FULLPATH}"
CACHE INTERNAL "full path to the compiler cmake found")
ENDIF(NOT CMAKE_RC_COMPILER_INIT)
SET(CMAKE_RC_COMPILER ${CMAKE_RC_COMPILER_INIT} CACHE STRING "RC compiler")
ENDIF(NOT CMAKE_RC_COMPILER)
MARK_AS_ADVANCED(CMAKE_RC_COMPILER)
# configure variables set in this file for fast reload later on
CONFIGURE_FILE(${CMAKE_ROOT}/Modules/CMakeRCCompiler.cmake.in
${CMAKE_BINARY_DIR}/CMakeRCCompiler.cmake IMMEDIATE)
SET(CMAKE_RC_COMPILER_ENV_VAR "RC")

View File

@ -24,15 +24,15 @@ IF(NOT CMAKE_SHARED_LIBRARY_Fortran_FLAGS)
ENDIF(NOT CMAKE_SHARED_LIBRARY_Fortran_FLAGS)
IF(NOT CMAKE_SHARED_LIBRARY_LINK_Fortran_FLAGS)
SET(CMAKE_SHARED_LIBRARY_LINK_Fortran_FLAGS ${CMAKE_SHARED_LIBRARY_LINK_FLAGS})
SET(CMAKE_SHARED_LIBRARY_LINK_Fortran_FLAGS ${CMAKE_SHARED_LIBRARY_LINK_C_FLAGS})
ENDIF(NOT CMAKE_SHARED_LIBRARY_LINK_Fortran_FLAGS)
IF(NOT CMAKE_SHARED_LIBRARY_RUNTIME_Fortran_FLAG)
SET(CMAKE_SHARED_LIBRARY_RUNTIME_Fortran_FLAG ${CMAKE_SHARED_LIBRARY_RUNTIME_FLAG})
SET(CMAKE_SHARED_LIBRARY_RUNTIME_Fortran_FLAG ${CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG})
ENDIF(NOT CMAKE_SHARED_LIBRARY_RUNTIME_Fortran_FLAG)
IF(NOT CMAKE_SHARED_LIBRARY_RUNTIME_Fortran_FLAG_SEP)
SET(CMAKE_SHARED_LIBRARY_RUNTIME_Fortran_FLAG_SEP ${CMAKE_SHARED_LIBRARY_RUNTIME_FLAG_SEP})
SET(CMAKE_SHARED_LIBRARY_RUNTIME_Fortran_FLAG_SEP ${CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP})
ENDIF(NOT CMAKE_SHARED_LIBRARY_RUNTIME_Fortran_FLAG_SEP)
# repeat for modules
@ -49,13 +49,21 @@ IF(NOT CMAKE_SHARED_MODULE_LINK_Fortran_FLAGS)
ENDIF(NOT CMAKE_SHARED_MODULE_LINK_Fortran_FLAGS)
IF(NOT CMAKE_SHARED_MODULE_RUNTIME_Fortran_FLAG)
SET(CMAKE_SHARED_MODULE_RUNTIME_Fortran_FLAG ${CMAKE_SHARED_MODULE_RUNTIME_FLAG})
SET(CMAKE_SHARED_MODULE_RUNTIME_Fortran_FLAG ${CMAKE_SHARED_MODULE_RUNTIME_C_FLAG})
ENDIF(NOT CMAKE_SHARED_MODULE_RUNTIME_Fortran_FLAG)
IF(NOT CMAKE_SHARED_MODULE_RUNTIME_Fortran_FLAG_SEP)
SET(CMAKE_SHARED_MODULE_RUNTIME_Fortran_FLAG_SEP ${CMAKE_SHARED_MODULE_RUNTIME_FLAG_SEP})
SET(CMAKE_SHARED_MODULE_RUNTIME_Fortran_FLAG_SEP ${CMAKE_SHARED_MODULE_RUNTIME_C_FLAG_SEP})
ENDIF(NOT CMAKE_SHARED_MODULE_RUNTIME_Fortran_FLAG_SEP)
IF(NOT CMAKE_INCLUDE_FLAG_Fortran)
SET(CMAKE_INCLUDE_FLAG_Fortran ${CMAKE_INCLUDE_FLAG_C})
ENDIF(NOT CMAKE_INCLUDE_FLAG_Fortran)
IF(NOT CMAKE_INCLUDE_FLAG_SEP_Fortran)
SET(CMAKE_INCLUDE_FLAG_SEP_Fortran ${CMAKE_INCLUDE_FLAG_SEP_C})
ENDIF(NOT CMAKE_INCLUDE_FLAG_SEP_Fortran)
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. With Visual Studio IDE projects all commands are done without /nologo.")
SET (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS_ENV_INIT} $ENV{FFLAGS} ${CMAKE_Fortran_FLAGS_INIT}" CACHE STRING

View File

@ -7,9 +7,11 @@ 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_SHARED_LIBRARY_LINK_C_FLAGS "") # +s, flag for exe link to use shared lib
SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "") # -rpath
SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP "") # : or empty
SET(CMAKE_INCLUDE_FLAG_C "-I") # -I
SET(CMAKE_INCLUDE_FLAG_C_SEP "") # , or empty
SET(CMAKE_LIBRARY_PATH_FLAG "-L")
SET(CMAKE_LINK_LIBRARY_FLAG "-l")
IF(CMAKE_COMPILER_IS_GNUCC)

View File

@ -1,75 +1,8 @@
SET(CMAKE_JAVA_COMPILER "@CMAKE_JAVA_COMPILER@")
SET(CMAKE_JAVA_RUNTIME "@CMAKE_JAVA_RUNTIME@")
SET(CMAKE_JAVA_ARCHIVE "@CMAKE_JAVA_ARCHIVE@")
SET(CMAKE_JAVA_COMPILER_LOADED 1)
SET(CMAKE_JAVA_RUNTIME_LOADED 1)
SET(CMAKE_JAVA_ARCHIVE_LOADED 1)
SET(CMAKE_Java_COMPILER "@CMAKE_Java_COMPILER@")
SET(CMAKE_Java_RUNTIME "@CMAKE_Java_RUNTIME@")
SET(CMAKE_Java_ARCHIVE "@CMAKE_Java_ARCHIVE@")
SET(CMAKE_Java_COMPILER_LOADED 1)
MACRO(ADD_JAVA_LIBRARY LIBRARYNAME SOURCES)
IF(CMAKE_JAVA_COMPILER AND CMAKE_JAVA_ARCHIVE)
SET(CMAKE_JAVA_INCLUDE_PATH ${CMAKE_JAVA_INCLUDE_PATH}
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${LIBRARY_OUTPUT_PATH})
SET(CMAKE_JAVA_INCLUDE_PATH_TOTAL "")
FOREACH(DIR ${CMAKE_JAVA_INCLUDE_PATH})
SET(CMAKE_JAVA_INCLUDE_PATH_TOTAL "${CMAKE_JAVA_INCLUDE_PATH_TOTAL}:${DIR}")
ENDFOREACH(DIR)
IF(WIN32)
STRING(REGEX REPLACE "/" "\\\\" CMAKE_JAVA_INCLUDE_PATH_TOTAL
${CMAKE_JAVA_INCLUDE_PATH_TOTAL})
STRING(REGEX REPLACE "/" "\\\\" CMAKE_JAVA_CLASS_OUTPUT_PATH
${CMAKE_CURRENT_BINARY_DIR})
STRING(REGEX REPLACE ":([^\\/])" "\\\\;\\1" CMAKE_JAVA_INCLUDE_PATH_TOTAL
${CMAKE_JAVA_INCLUDE_PATH_TOTAL})
ELSE(WIN32)
SET(CMAKE_JAVA_CLASS_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR})
ENDIF(WIN32)
ADD_CUSTOM_TARGET(${LIBRARYNAME}_target ALL)
SET(CMAKE_JAVA_ALL_CLASS_FILES "")
SET(CMAKE_JAVA_ALL_CLASS_FILE_PATHS "")
SET(SKIP 1)
FOREACH(SOURCE ${ARGV})
IF(SKIP)
SET(SKIP 0)
ELSE(SKIP)
GET_FILENAME_COMPONENT(CLASS_FILE_PATH ${SOURCE} PATH)
GET_FILENAME_COMPONENT(CLASS_FILE_NAME ${SOURCE} NAME_WE)
SET(CLASS_FILE "${CLASS_FILE_PATH}/${CLASS_FILE_NAME}")
ADD_CUSTOM_COMMAND(SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/${SOURCE}
COMMAND ${CMAKE_JAVA_COMPILER}
ARGS ${CMAKE_JAVA_COMPILE_FLAGS}
-classpath ${CMAKE_JAVA_INCLUDE_PATH_TOTAL}
${CMAKE_CURRENT_SOURCE_DIR}/${SOURCE}
-d ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/
TARGET ${LIBRARYNAME}_target
OUTPUTS "${CMAKE_JAVA_CLASS_OUTPUT_PATH}/${CLASS_FILE}.class"
COMMENT "Java File" )
SET(CMAKE_JAVA_ALL_CLASS_FILES ${CMAKE_JAVA_ALL_CLASS_FILES} ${CLASS_FILE}.class)
SET(CMAKE_JAVA_ALL_CLASS_FILE_PATHS ${CMAKE_JAVA_ALL_CLASS_FILE_PATHS} ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/${CLASS_FILE}.class)
ENDIF(SKIP)
ENDFOREACH(SOURCE)
IF(LIBRARY_OUTPUT_PATH)
SET(CMAKE_JAVA_LIBRARY_OUTPUT_PATH ${LIBRARY_OUTPUT_PATH})
ELSE(LIBRARY_OUTPUT_PATH)
SET(CMAKE_JAVA_LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR})
ENDIF(LIBRARY_OUTPUT_PATH)
ADD_CUSTOM_COMMAND(SOURCE ${CMAKE_JAVA_ALL_CLASS_FILE_PATHS}
COMMAND ${CMAKE_COMMAND}
ARGS -E chdir ${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_JAVA_ARCHIVE}
-cvf ${CMAKE_JAVA_LIBRARY_OUTPUT_PATH}/${LIBRARYNAME}.jar ${CMAKE_JAVA_ALL_CLASS_FILES}
TARGET ${LIBRARYNAME}_target
DEPENDS ${CMAKE_JAVA_ALL_CLASS_FILE_PATHS}
OUTPUTS ${CMAKE_JAVA_LIBRARY_OUTPUT_PATH}/${LIBRARYNAME}.jar
COMMENT "Java Archive")
ADD_CUSTOM_COMMAND(SOURCE ${LIBRARYNAME}_target
TARGET ${LIBRARYNAME}_target
DEPENDS ${CMAKE_JAVA_LIBRARY_OUTPUT_PATH}/${LIBRARYNAME}.jar)
ELSE(CMAKE_JAVA_COMPILER AND CMAKE_JAVA_ARCHIVE)
MESSAGE(SEND_ERROR "Java compiler and/or Java archiver not found")
ENDIF(CMAKE_JAVA_COMPILER AND CMAKE_JAVA_ARCHIVE)
ENDMACRO(ADD_JAVA_LIBRARY LIBRARYNAME SOURCES)
SET(CMAKE_Java_SOURCE_FILE_EXTENSIONS java)
SET(CMAKE_Java_LINKER_PREFERENCE Prefered)
SET(CMAKE_Java_OUTPUT_EXTENSION .class)

View File

@ -1 +1,21 @@
# this is a place holder if java needed flags for javac they would go here.
SET(CMAKE_STATIC_LIBRARY_SUFFIX_Java ".jar")
IF(NOT CMAKE_Java_CREATE_STATIC_LIBRARY)
SET(CMAKE_Java_CREATE_STATIC_LIBRARY
"<CMAKE_Java_ARCHIVE> -cf <TARGET> *.class")
# should be this <OBJECTS> but compling a java file can create more than one .class file
# so for now get all of them
ENDIF(NOT CMAKE_Java_CREATE_STATIC_LIBRARY)
# compile a Java file into an object file
IF(NOT CMAKE_Java_COMPILE_OBJECT)
SET(CMAKE_Java_COMPILE_OBJECT
"<CMAKE_Java_COMPILER> <FLAGS> <SOURCE> -d \"<CMAKE_CURRENT_BINARY_DIR>\"")
ENDIF(NOT CMAKE_Java_COMPILE_OBJECT)
# set java include flag option and the separator for multiple include paths
SET(CMAKE_INCLUDE_FLAG_Java "-classpath ")
IF(WIN32 AND NOT CYGWIN)
SET(CMAKE_INCLUDE_FLAG_SEP_Java ";")
ELSE(WIN32 AND NOT CYGWIN)
SET(CMAKE_INCLUDE_FLAG_SEP_Java ":")
ENDIF(WIN32 AND NOT CYGWIN)

View File

@ -0,0 +1,4 @@
SET(CMAKE_RC_COMPILER "@CMAKE_RC_COMPILER@")
SET(CMAKE_RC_COMPILER_LOADED 1)
SET(CMAKE_RC_SOURCE_FILE_EXTENSIONS rc)
SET(CMAKE_RC_OUTPUT_EXTENSION .res)

View File

@ -0,0 +1,29 @@
# This file sets the basic flags for the Fortran language in CMake.
# It also loads the available platform file for the system-compiler
# if it exists.
GET_FILENAME_COMPONENT(CMAKE_BASE_NAME ${CMAKE_RC_COMPILER} NAME_WE)
SET(CMAKE_SYSTEM_AND_RC_COMPILER_INFO_FILE
${CMAKE_ROOT}/Modules/Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME}.cmake)
INCLUDE(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME} OPTIONAL)
SET (CMAKE_RC_FLAGS "${CMAKE_RC_FLAGS_ENV_INIT} $ENV{RCFLAGS} ${CMAKE_RC_FLAGS_INIT}" CACHE STRING
"Flags for Fortran compiler.")
# now define the following rule variables
# CMAKE_RC_COMPILE_OBJECT
# compile a Resource file into an object file
IF(NOT CMAKE_RC_COMPILE_OBJECT)
SET(CMAKE_RC_COMPILE_OBJECT
"<CMAKE_RC_COMPILER> <FLAGS> /fo<OBJECT> <SOURCE>")
ENDIF(NOT CMAKE_RC_COMPILE_OBJECT)
MARK_AS_ADVANCED(
CMAKE_RC_FLAGS
)
# set this variable so we can avoid loading this more than once.
SET(CMAKE_RC_INFOMATION_LOADED 1)

View File

@ -29,9 +29,9 @@ ENDIF(EXISTS ${CMAKE_SYSTEM_INFO_FILE})
IF(NOT CMAKE_MODULE_EXISTS)
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})
SET(CMAKE_SHARED_MODULE_RUNTIME_FLAG ${CMAKE_SHARED_LIBRARY_RUNTIME_FLAG})
SET(CMAKE_SHARED_MODULE_RUNTIME_FLAG_SEP ${CMAKE_SHARED_LIBRARY_RUNTIME_FLAG_SEP})
SET(CMAKE_SHARED_MODULE_LINK_FLAGS ${CMAKE_SHARED_LIBRARY_LINK_C_FLAGS})
SET(CMAKE_SHARED_MODULE_RUNTIME_C_FLAG ${CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG})
SET(CMAKE_SHARED_MODULE_RUNTIME_C_FLAG_SEP ${CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP})
ENDIF(NOT CMAKE_MODULE_EXISTS)

View File

@ -0,0 +1,5 @@
# This file is used by EnableLanguage in cmGlobalGenerator to
# determine that that selected Fortran compiler can actually compile
# and link the most basic of programs. If not, a fatal error
# is set and cmake stops processing commands and will not generate
# any makefiles or projects.

View File

@ -0,0 +1,8 @@
# This file is used by EnableLanguage in cmGlobalGenerator to
# determine that that selected RC compiler can actually compile
# and link the most basic of programs. If not, a fatal error
# is set and cmake stops processing commands and will not generate
# any makefiles or projects.
# For now there is no way to do a try compile on just a .rc file
# so just do nothing in here.

View File

@ -2,7 +2,7 @@ SET(CMAKE_SHARED_LIBRARY_PREFIX "lib") # lib
SET(CMAKE_SHARED_LIBRARY_SUFFIX ".so") # .so
SET(CMAKE_DL_LIBS "-lld")
SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-G -Wl,-brtl") # -shared
SET(CMAKE_SHARED_LIBRARY_LINK_FLAGS "-Wl,-brtl,-bexpall") # +s, flag for exe link to use shared lib
SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "-Wl,-brtl,-bexpall") # +s, flag for exe link to use shared lib
IF(CMAKE_COMPILER_IS_GNUCXX)
SET(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "-shared -Wl,-G") # -shared
ENDIF(CMAKE_COMPILER_IS_GNUCXX)

View File

@ -2,8 +2,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
SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") # +s, flag for exe link to use shared lib
SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,") # -rpath
SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":") # : or empty
ENDIF(EXISTS /usr/include/dlfcn.h)
# include the gcc flags

View File

@ -1,15 +1,15 @@
SET(CMAKE_SHARED_LIBRARY_SUFFIX ".sl") # .so
SET(CMAKE_DL_LIBS "-ldld")
SET(CMAKE_SHARED_LIBRARY_RUNTIME_FLAG_SEP ":") # : or empty
SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":") # : or empty
# fortran
IF(CMAKE_COMPILER_IS_GNUG77)
SET(CMAKE_SHARED_LIBRARY_Fortran_FLAGS "-fPIC") # -pic
SET(CMAKE_SHARED_LIBRARY_CREATE_Fortran_FLAGS "-shared -Wl,-E -Wl,-b") # -shared
SET(CMAKE_SHARED_LIBRARY_LINK_FLAGS "-Wl,+s -Wl,-E") # +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_LINK_C_FLAGS "-Wl,+s -Wl,-E") # +s, flag for exe link to use shared lib
SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,+b") # -rpath
SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":") # : or empty
SET(CMAKE_SHARED_LIBRARY_SONAME_Fortran_FLAG "-Wl,+h")
SET(CMAKE_SHARED_LIBRARY_Fortran_FLAGS "-fPIC") # -pic
ELSE(CMAKE_COMPILER_IS_GNUG77)
@ -18,8 +18,8 @@ ELSE(CMAKE_COMPILER_IS_GNUG77)
"ld <CMAKE_SHARED_LIBRARY_CREATE_Fortran_FLAGS> <CMAKE_SHARED_LIBRARY_SONAME_Fortran_FLAG><TARGET_SONAME> <LINK_FLAGS> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>")
SET(CMAKE_SHARED_LIBRARY_Fortran_FLAGS "+Z") # -pic
SET(CMAKE_SHARED_LIBRARY_CREATE_Fortran_FLAGS "-E -b -L/usr/lib") # -shared
SET(CMAKE_SHARED_LIBRARY_LINK_FLAGS "-Wl,+s -Wl,-E") # +s, flag for exe link to use shared lib
SET(CMAKE_SHARED_LIBRARY_RUNTIME_FLAG "+b") # -rpath
SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "-Wl,+s -Wl,-E") # +s, flag for exe link to use shared lib
SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "+b") # -rpath
SET(CMAKE_SHARED_LIBRARY_SONAME_Fortran_FLAG "+h")
ENDIF(CMAKE_COMPILER_IS_GNUG77)
# C compiler
@ -27,9 +27,9 @@ 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 -Wl,-E") # +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_LINK_C_FLAGS "-Wl,+s -Wl,-E") # +s, flag for exe link to use shared lib
SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,+b") # -rpath
SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":") # : or empty
SET(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-Wl,+h")
SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-fPIC") # -pic
ELSE(CMAKE_COMPILER_IS_GNUCC)
@ -40,8 +40,8 @@ ELSE(CMAKE_COMPILER_IS_GNUCC)
"ld <CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS> <CMAKE_SHARED_LIBRARY_SONAME_C_FLAG><TARGET_SONAME> <LINK_FLAGS> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>")
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 "-Wl,+s -Wl,-E") # +s, flag for exe link to use shared lib
SET(CMAKE_SHARED_LIBRARY_RUNTIME_FLAG "+b") # -rpath
SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "-Wl,+s -Wl,-E") # +s, flag for exe link to use shared lib
SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "+b") # -rpath
SET(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "+h")
ENDIF(CMAKE_COMPILER_IS_GNUCC)

View File

@ -1,8 +1,8 @@
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
SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,") # -rpath
SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP "") # : or empty
IF(NOT CMAKE_COMPILER_IS_GNUCXX)
SET(CMAKE_CXX_CREATE_STATIC_LIBRARY
"<CMAKE_CXX_COMPILER> -ar -o <TARGET> <OBJECTS>")

View File

@ -1,8 +1,8 @@
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
SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,") # -rpath
SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP "") # : or empty
SET(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-Wl,-soname,")
SET(CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG "-Wl,-soname,")
IF(NOT CMAKE_COMPILER_IS_GNUCXX)

View File

@ -13,6 +13,6 @@ SET(CMAKE_CXX_LINK_EXECUTABLE
"<CMAKE_CXX_COMPILER> --prelink_objects <OBJECTS>"
"<CMAKE_CXX_COMPILER> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
SET(CMAKE_SHARED_LIBRARY_RUNTIME_FLAG "")
SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "")
SET(CMAKE_SHARED_LIBRARY_C_FLAGS "")
SET(CMAKE_SHARED_LIBRARY_LINK_FLAGS "")
SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")

View File

@ -2,8 +2,8 @@
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 ":")
SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "-rdynamic")
SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,")
SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":")
SET(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-Wl,-soname,")
SET(CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG "-Wl,-soname,")

View File

@ -2,7 +2,7 @@ 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")
SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "-Wl,-Bexport")
ENDIF(CMAKE_SYSTEM MATCHES "MP-RAS-02*.")

View File

@ -2,7 +2,7 @@ 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
SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") # +s, flag for exe link to use shared lib
SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,") # -rpath
SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":") # : or empty
ENDIF(EXISTS /usr/include/dlfcn.h)

View File

@ -19,11 +19,11 @@ IF(CMAKE_SYSTEM MATCHES "OSF1-V.*")
SET(CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG "-rpath ")
ENDIF(CMAKE_COMPILER_IS_GNUCXX)
IF(CMAKE_COMPILER_IS_GNUCC)
SET(CMAKE_SHARED_LIBRARY_RUNTIME_FLAG "-Wl,-rpath,")
SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,")
ELSE(CMAKE_COMPILER_IS_GNUCC)
SET(CMAKE_SHARED_LIBRARY_RUNTIME_FLAG "-rpath ")
SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-rpath ")
ENDIF(CMAKE_COMPILER_IS_GNUCC)
SET(CMAKE_SHARED_LIBRARY_RUNTIME_FLAG_SEP ":")
SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":")
ENDIF(CMAKE_SYSTEM MATCHES "OSF1-V.*")

View File

@ -1,4 +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")
SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "-Wl,-D,08000000")

View File

@ -1,8 +1,8 @@
IF(CMAKE_SYSTEM MATCHES "SunOS-4.*")
SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-PIC")
SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared -Wl,-r")
SET(CMAKE_SHARED_LIBRARY_RUNTIME_FLAG "-Wl,-R")
SET(CMAKE_SHARED_LIBRARY_RUNTIME_FLAG_SEP ":")
SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-R")
SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":")
SET(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-h")
SET(CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG "-h")
ENDIF(CMAKE_SYSTEM MATCHES "SunOS-4.*")
@ -10,8 +10,8 @@ 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 ":")
SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-R")
SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":")
SET(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-h")
SET(CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG "-h")
SET(CMAKE_SHARED_LIBRARY_CXX_FLAGS "-KPIC")
@ -21,8 +21,8 @@ IF(CMAKE_SYSTEM MATCHES "SunOS-5*.")
IF(CMAKE_COMPILER_IS_GNUCC)
SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-fPIC")
SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared")
SET(CMAKE_SHARED_LIBRARY_RUNTIME_FLAG "-Wl,-R")
SET(CMAKE_SHARED_LIBRARY_RUNTIME_FLAG_SEP ":")
SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-R")
SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":")
SET(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-Wl,-h")
ENDIF(CMAKE_COMPILER_IS_GNUCC)
IF(CMAKE_COMPILER_IS_GNUCXX)

View File

@ -1,4 +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")
SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "-Wl,-D,08000000")

View File

@ -1,2 +1,2 @@
SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-K PIC")
SET(CMAKE_SHARED_LIBRARY_LINK_FLAGS "-Wl,-Bexport")
SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "-Wl,-Bexport")

View File

@ -32,6 +32,7 @@ SET(CMAKE_C_COMPILE_OBJECT
SET(CMAKE_C_LINK_EXECUTABLE
"<CMAKE_C_COMPILER> /nologo ${CMAKE_START_TEMP_FILE} <FLAGS> <OBJECTS> /Fe<TARGET> -link <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES>${CMAKE_END_TEMP_FILE}")
ENABLE_LANGUAGE(RC)
SET(CMAKE_COMPILE_RESOURCE "rc <FLAGS> /fo<OBJECT> <SOURCE>")
SET(CMAKE_CXX_LINK_EXECUTABLE
@ -60,35 +61,38 @@ IF(CMAKE_GENERATOR MATCHES "Visual Studio 8")
SET(CMAKE_COMPILER_2005 1)
ENDIF(CMAKE_GENERATOR MATCHES "Visual Studio 8")
IF(CMAKE_GENERATOR MATCHES "NMake Makefiles")
EXEC_PROGRAM(${CMAKE_C_COMPILER}
ARGS /nologo -EP \"${CMAKE_ROOT}/Modules/CMakeTestNMakeCLVersion.c\"
OUTPUT_VARIABLE CMAKE_COMPILER_OUTPUT
RETURN_VALUE CMAKE_COMPILER_RETURN
)
IF(NOT CMAKE_COMPILER_RETURN)
IF("${CMAKE_COMPILER_OUTPUT}" MATCHES ".*VERSION=1[3-9][0-9][0-9].*" )
SET(CMAKE_COMPILER_SUPPORTS_PDBTYPE 0)
ENDIF("${CMAKE_COMPILER_OUTPUT}" MATCHES ".*VERSION=1[3-9][0-9][0-9].*" )
IF("${CMAKE_COMPILER_OUTPUT}" MATCHES ".*VERSION=1[4-9][0-9][0-9].*" )
SET(CMAKE_COMPILER_2005 1)
ENDIF("${CMAKE_COMPILER_OUTPUT}" MATCHES ".*VERSION=1[4-9][0-9][0-9].*" )
ENDIF(NOT CMAKE_COMPILER_RETURN)
MAKE_DIRECTORY("${CMAKE_BINARY_DIR}/CMakeTmp")
# try to figure out if we are running the free command line
# tools from Microsoft. These tools do not provide debug libraries,
# so the link flags used have to be different.
EXEC_PROGRAM(${CMAKE_CXX_COMPILER} ${CMAKE_BINARY_DIR}/CMakeTmp
ARGS /nologo /MD /EHsc
\"${CMAKE_ROOT}/Modules/CMakeTestForFreeVC.cxx\"
OUTPUT_VARIABLE CMAKE_COMPILER_OUTPUT
RETURN_VALUE CMAKE_COMPILER_RETURN
)
IF(CMAKE_COMPILER_RETURN)
SET(CMAKE_USING_VC_FREE_TOOLS 1)
ELSE(CMAKE_COMPILER_RETURN)
SET(CMAKE_USING_VC_FREE_TOOLS 0)
ENDIF(CMAKE_COMPILER_RETURN)
IF(NOT CMAKE_VC_COMPILER_TESTS_RUN)
SET(CMAKE_VC_COMPILER_TESTS 1)
EXEC_PROGRAM(${CMAKE_C_COMPILER}
ARGS /nologo -EP \"${CMAKE_ROOT}/Modules/CMakeTestNMakeCLVersion.c\"
OUTPUT_VARIABLE CMAKE_COMPILER_OUTPUT
RETURN_VALUE CMAKE_COMPILER_RETURN
)
IF(NOT CMAKE_COMPILER_RETURN)
IF("${CMAKE_COMPILER_OUTPUT}" MATCHES ".*VERSION=1[3-9][0-9][0-9].*" )
SET(CMAKE_COMPILER_SUPPORTS_PDBTYPE 0)
ENDIF("${CMAKE_COMPILER_OUTPUT}" MATCHES ".*VERSION=1[3-9][0-9][0-9].*" )
IF("${CMAKE_COMPILER_OUTPUT}" MATCHES ".*VERSION=1[4-9][0-9][0-9].*" )
SET(CMAKE_COMPILER_2005 1)
ENDIF("${CMAKE_COMPILER_OUTPUT}" MATCHES ".*VERSION=1[4-9][0-9][0-9].*" )
ENDIF(NOT CMAKE_COMPILER_RETURN)
# try to figure out if we are running the free command line
# tools from Microsoft. These tools do not provide debug libraries,
# so the link flags used have to be different.
MAKE_DIRECTORY("${CMAKE_BINARY_DIR}/CMakeTmp2")
EXEC_PROGRAM(${CMAKE_CXX_COMPILER} ${CMAKE_BINARY_DIR}/CMakeTmp2
ARGS /nologo /MD /EHsc
\"${CMAKE_ROOT}/Modules/CMakeTestForFreeVC.cxx\"
OUTPUT_VARIABLE CMAKE_COMPILER_OUTPUT
RETURN_VALUE CMAKE_COMPILER_RETURN
)
IF(CMAKE_COMPILER_RETURN)
SET(CMAKE_USING_VC_FREE_TOOLS 1)
ELSE(CMAKE_COMPILER_RETURN)
SET(CMAKE_USING_VC_FREE_TOOLS 0)
ENDIF(CMAKE_COMPILER_RETURN)
SET(CMAKE_VC_COMPILER_TESTS_RUN 1 CACHE INTERNAL "")
ENDIF(NOT CMAKE_VC_COMPILER_TESTS_RUN)
ENDIF(CMAKE_GENERATOR MATCHES "NMake Makefiles")

View File

@ -8,8 +8,8 @@ SET(CMAKE_SHARED_MODULE_SUFFIX ".dll") # .so
SET(CMAKE_DL_LIBS "")
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_SHARED_LIBRARY_LINK_C_FLAGS "") # +s, flag for exe link to use shared lib
SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "") # -rpath
SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP "") # : or empty
SET(CMAKE_LIBRARY_PATH_FLAG "-L")
SET(CMAKE_LINK_LIBRARY_FLAG "-l")

View File

@ -636,12 +636,13 @@ IF(BUILD_TESTING)
)
ENDIF (CTEST_TEST_CTEST)
IF(CMAKE_GENERATOR MATCHES "Makefiles")
# see if we can find a fortran compiler on the machine
# if so, add the fortran test and see if it works.
SET(CMAKE_Fortran_COMPILER_LIST ifort ifc efc f95 pgf95
lf95 xlf95 fort gfortran f90 pgf90 xlf90 epcf90 f77
fort77 frt pgf77 xlf fl32 af77 g77 )
lf95 xlf95 fort gfortran f90 pgf90 xlf90
epcf90 f77 fort77 frt pgf77 xlf fl32 af77 g77 )
FIND_PROGRAM(CMAKE_Fortran_COMPILER_FULLPATH NAMES ${CMAKE_Fortran_COMPILER_LIST} )
MARK_AS_ADVANCED(CMAKE_Fortran_COMPILER_FULLPATH)
IF(CMAKE_Fortran_COMPILER_FULLPATH)
@ -650,13 +651,27 @@ IF(BUILD_TESTING)
"${CMake_SOURCE_DIR}/Tests/Fortran"
"${CMake_BINARY_DIR}/Tests/Fortran"
--build-generator ${CMAKE_GENERATOR}
--build-project Simple
--build-project testf
--build-makeprogram ${MAKEPROGRAM}
--build-two-config
--test-command testf)
ENDIF(CMAKE_Fortran_COMPILER_FULLPATH)
INCLUDE(FindJava)
IF(JAVA_COMPILE)
ADD_TEST(Java ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMake_SOURCE_DIR}/Tests/Java"
"${CMake_BINARY_DIR}/Tests/Java"
--build-generator ${CMAKE_GENERATOR}
--build-project hello
--build-makeprogram ${MAKEPROGRAM}
--build-two-config
--build-run-dir "${CMake_BINARY_DIR}/Tests/Java/"
--test-command ${JAVA_RUNTIME} -classpath hello.jar HelloWorld)
ENDIF(JAVA_COMPILE)
ENDIF(CMAKE_GENERATOR MATCHES "Makefiles")
IF (CMAKE_WXWINDOWS_WXCONFIG_EXECUTABLE OR WXWINDOWS_INCLUDE_DIR)
# Will be set if the wxwindows gui is on
ADD_TEST(UseWX ${CMAKE_CTEST_COMMAND}

View File

@ -80,6 +80,7 @@
#include "cmAbstractFilesCommand.cxx"
#include "cmAuxSourceDirectoryCommand.cxx"
#include "cmExportLibraryDependencies.cxx"
#include "cmEnableLanguageCommand.cxx"
#include "cmFLTKWrapUICommand.cxx"
#include "cmGetCMakePropertyCommand.cxx"
#include "cmGetDirectoryPropertyCommand.cxx"
@ -171,6 +172,7 @@ void GetPredefinedCommands(std::list<cmCommand*>& commands)
#if defined(CMAKE_BUILD_WITH_CMAKE)
commands.push_back(new cmAbstractFilesCommand);
commands.push_back(new cmAuxSourceDirectoryCommand);
commands.push_back(new cmEnableLanguageCommand);
commands.push_back(new cmExportLibraryDependenciesCommand);
commands.push_back(new cmFLTKWrapUICommand);
commands.push_back(new cmGetCMakePropertyCommand);

View File

@ -0,0 +1,30 @@
/*=========================================================================
Program: CMake - Cross-Platform Makefile Generator
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include "cmEnableLanguageCommand.h"
// cmEnableLanguageCommand
bool cmEnableLanguageCommand::InitialPass(std::vector<std::string> const& args)
{
if(args.size() < 1 )
{
this->SetError("ENABLE_LANGUAGE called with incorrect number of arguments");
return false;
}
m_Makefile->EnableLanguage(args);
return true;
}

View File

@ -0,0 +1,84 @@
/*=========================================================================
Program: CMake - Cross-Platform Makefile Generator
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef cmEnableLanguageCommand_h
#define cmEnableLanguageCommand_h
#include "cmCommand.h"
/** \class cmEnableLanguageCommand
* \brief Specify the name for this build project.
*
* cmEnableLanguageCommand is used to specify a name for this build project.
* It is defined once per set of CMakeList.txt files (including
* all subdirectories). Currently it just sets the name of the workspace
* file for Microsoft Visual C++
*/
class cmEnableLanguageCommand : public cmCommand
{
public:
/**
* This is a virtual constructor for the command.
*/
virtual cmCommand* Clone()
{
return new cmEnableLanguageCommand;
}
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
virtual bool InitialPass(std::vector<std::string> const& args);
/**
* The name of the command as specified in CMakeList.txt.
*/
virtual const char* GetName() {return "ENABLE_LANGUAGE";}
/**
* This determines if the command gets propagated down
* to makefiles located in subdirectories.
*/
virtual bool IsInherited()
{
return true;
}
/**
* Succinct documentation.
*/
virtual const char* GetTerseDocumentation()
{
return "Set a name for the entire project.";
}
/**
* More documentation.
*/
virtual const char* GetFullDocumentation()
{
return
" ENABLE_LANGUAGE(languageName)\n"
" This command enables support for the named language in CMake.";
}
cmTypeMacro(cmEnableLanguageCommand, cmCommand);
};
#endif

View File

@ -190,10 +190,10 @@ void cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
}
needTestLanguage = true; // must test a language after finding it
// read determine LANG compiler
std::string determinCompiler = "CMakeDetermine";
determinCompiler += lang;
determinCompiler += "Compiler.cmake";
std::string determineFile = mf->GetModulesFile(determinCompiler.c_str());
std::string determineCompiler = "CMakeDetermine";
determineCompiler += lang;
determineCompiler += "Compiler.cmake";
std::string determineFile = mf->GetModulesFile(determineCompiler.c_str());
if(!mf->ReadListFile(0,determineFile.c_str()))
{
cmSystemTools::Error("Could not find cmake module file:", determineFile.c_str());
@ -310,8 +310,31 @@ void cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
}
}
const char* cmGlobalGenerator::GetLanguageOutputExtensionForLanguage(const char* lang)
{
if(m_LanguageToOutputExtension.count(lang) > 0)
{
return m_LanguageToOutputExtension[lang].c_str();
}
return "";
}
const char* cmGlobalGenerator::GetLanguageOutputExtensionFromExtension(const char* ext)
{
const char* lang = this->GetLanguageFromExtension(ext);
return this->GetLanguageOutputExtensionForLanguage(lang);
}
const char* cmGlobalGenerator::GetLanguageFromExtension(const char* ext)
{
// if there is an extension and it starts with . then
// move past the . because the extensions are not stored with a .
// in the map
if(ext && *ext == '.')
{
++ext;
}
if(m_ExtensionToLanguage.count(ext) > 0)
{
return m_ExtensionToLanguage[ext].c_str();
@ -325,8 +348,28 @@ void cmGlobalGenerator::SetLanguageEnabled(const char* l, cmMakefile* mf)
{
return;
}
std::string outputExtensionVar = std::string("CMAKE_") +
std::string(l) + std::string("_OUTPUT_EXTENSION");
const char* outputExtension = mf->GetDefinition(outputExtensionVar.c_str());
if(outputExtension)
{
m_LanguageToOutputExtension[l] = outputExtension;
}
std::string linkerPrefVar = std::string("CMAKE_") +
std::string(l) + std::string("_LINKER_PREFERENCE");
const char* linkerPref = mf->GetDefinition(linkerPrefVar.c_str());
if(!linkerPref)
{
linkerPref = "None";
}
m_LanguageToLinkerPreference[l] = linkerPref;
std::string extensionsVar = std::string("CMAKE_") +
std::string(l) + std::string("_SOURCE_FILE_EXTENSIONS");
std::string ignoreExtensionsVar = std::string("CMAKE_") +
std::string(l) + std::string("_IGNORE_EXTENSIONS");
std::string ignoreExts = mf->GetSafeDefinition(ignoreExtensionsVar.c_str());
std::string exts = mf->GetSafeDefinition(extensionsVar.c_str());
std::vector<std::string> extensionList;
cmSystemTools::ExpandListArgument(exts, extensionList);
@ -335,10 +378,19 @@ void cmGlobalGenerator::SetLanguageEnabled(const char* l, cmMakefile* mf)
{
m_ExtensionToLanguage[*i] = l;
}
cmSystemTools::ExpandListArgument(ignoreExts, extensionList);
for(std::vector<std::string>::iterator i = extensionList.begin();
i != extensionList.end(); ++i)
{
m_IgnoreExtensions[*i] = true;
}
m_LanguageEnabled[l] = true;
}
bool cmGlobalGenerator::IgnoreFile(const char* l)
{
return (m_IgnoreExtensions.count(l) > 0);
}
bool cmGlobalGenerator::GetLanguageEnabled(const char* l)
{
@ -609,6 +661,9 @@ void cmGlobalGenerator::EnableLanguagesFromGenerator(cmGlobalGenerator *gen )
// copy the enabled languages
this->m_LanguageEnabled = gen->m_LanguageEnabled;
this->m_ExtensionToLanguage = gen->m_ExtensionToLanguage;
this->m_IgnoreExtensions = gen->m_IgnoreExtensions;
this->m_LanguageToOutputExtension = gen->m_LanguageToOutputExtension;
this->m_LanguageToLinkerPreference = gen->m_LanguageToLinkerPreference;
}
//----------------------------------------------------------------------------
@ -635,3 +690,20 @@ bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root,
}
void cmGlobalGenerator::GetEnabledLanguages(std::vector<std::string>& lang)
{
for(std::map<cmStdString, bool>::iterator i = m_LanguageEnabled.begin();
i != m_LanguageEnabled.end(); ++i)
{
lang.push_back(i->first);
}
}
const char* cmGlobalGenerator::GetLinkerPreference(const char* lang)
{
if(m_LanguageToLinkerPreference.count(lang))
{
return m_LanguageToLinkerPreference[lang].c_str();
}
return "None";
}

View File

@ -72,7 +72,7 @@ public:
void SetLanguageEnabled(const char*, cmMakefile* mf);
bool GetLanguageEnabled(const char*);
void ClearEnabledLanguages();
void GetEnabledLanguages(std::vector<std::string>& lang);
/**
* Try to determine system infomation such as shared library
* extension, pthreads, byte order etc.
@ -107,6 +107,14 @@ public:
bool GetForceUnixPaths() {return m_ForceUnixPaths;}
///! return the language for the given extension
const char* GetLanguageFromExtension(const char* ext);
///! is an extension to be ignored
bool IgnoreFile(const char* ext);
///! What is the preference for linkers and this language (None or Prefered)
const char* GetLinkerPreference(const char* lang);
///! What is the output extension for a given language.
const char* GetLanguageOutputExtensionForLanguage(const char* lang);
///! What is the output extension for a given source file extension.
const char* GetLanguageOutputExtensionFromExtension(const char* lang);
protected:
bool IsExcluded(cmLocalGenerator* root, cmLocalGenerator* gen);
void FindMakeProgram(cmMakefile*);
@ -121,8 +129,13 @@ protected:
void RecursiveConfigure(cmLocalGenerator *lg, float start, float end);
private:
// If you add a new map here, make sure it is copied
// in EnableLanguagesFromGenerator
std::map<cmStdString, bool> m_IgnoreExtensions;
std::map<cmStdString, bool> m_LanguageEnabled;
std::map<cmStdString, cmStdString> m_LanguageToOutputExtension;
std::map<cmStdString, cmStdString> m_ExtensionToLanguage;
std::map<cmStdString, cmStdString> m_LanguageToLinkerPreference;
};
#endif

View File

@ -31,7 +31,7 @@ bool cmInstallFilesCommand::InitialPass(std::vector<std::string> const& argsIn)
m_TargetName = "INSTALL_FILES_"+args[0];
cmTarget& target = m_Makefile->GetTargets()[m_TargetName];
target.SetInAll(false);
target.SetType(cmTarget::INSTALL_FILES);
target.SetType(cmTarget::INSTALL_FILES, m_TargetName.c_str());
target.SetInstallPath(args[0].c_str());
if((args.size() > 1) && (args[1] == "FILES"))

View File

@ -29,7 +29,7 @@ bool cmInstallProgramsCommand::InitialPass(std::vector<std::string> const& args)
m_TargetName = "INSTALL_PROGRAMS_"+args[0];
cmTarget& target = m_Makefile->GetTargets()[m_TargetName];
target.SetInAll(false);
target.SetType(cmTarget::INSTALL_PROGRAMS);
target.SetType(cmTarget::INSTALL_PROGRAMS, m_TargetName.c_str());
target.SetInstallPath(args[0].c_str());
std::vector<std::string>::const_iterator s = args.begin();

View File

@ -519,3 +519,4 @@ std::string cmLocalGenerator::ConvertToRelativeOutputPath(const char* p)
}

View File

@ -309,32 +309,6 @@ void cmLocalUnixMakefileGenerator::OutputMakefile(const char* file,
}
std::string cmLocalUnixMakefileGenerator::GetOutputExtension(const char* s)
{
if(m_Makefile->IsOn("WIN32") && !(m_Makefile->IsOn("CYGWIN") || m_Makefile->IsOn("MINGW")))
{
std::string sourceExtension = s;
if(sourceExtension == "def")
{
return "";
}
if(sourceExtension == "ico" || sourceExtension == "rc2")
{
return "";
}
if(sourceExtension == "rc")
{
return ".res";
}
return ".obj";
}
else
{
return ".o";
}
}
std::string cmLocalUnixMakefileGenerator::GetBaseTargetName(const char* n,
const cmTarget& t)
{
@ -380,7 +354,7 @@ std::string cmLocalUnixMakefileGenerator::GetFullTargetName(const char* n,
const cmTarget& t)
{
const char* targetSuffix = t.GetProperty("SUFFIX");
const char* suffixVar = 0;
std::string suffixVar;
switch(t.GetType())
{
case cmTarget::STATIC_LIBRARY:
@ -400,9 +374,20 @@ std::string cmLocalUnixMakefileGenerator::GetFullTargetName(const char* n,
break;
}
// if there is no suffix on the target use the cmake definition
if(!targetSuffix && suffixVar)
if(!targetSuffix && suffixVar.size())
{
targetSuffix = m_Makefile->GetSafeDefinition(suffixVar);
// first check for a language specific suffix var
const char* ll = t.GetLinkerLanguage(this->GetGlobalGenerator());
if(ll)
{
std::string langSuff = suffixVar + std::string("_") + ll;
targetSuffix = m_Makefile->GetDefinition(langSuff.c_str());
}
// if there not a language specific suffix then use the general one
if(!targetSuffix)
{
targetSuffix = m_Makefile->GetSafeDefinition(suffixVar.c_str());
}
}
std::string name = this->GetBaseTargetName(n, t);
name += targetSuffix?targetSuffix:"";
@ -540,9 +525,10 @@ void cmLocalUnixMakefileGenerator::OutputTargetRules(std::ostream& fout)
{
if(!(*i)->GetPropertyAsBool("HEADER_FILE_ONLY") &&
!(*i)->GetCustomCommand())
{
std::string outExt(
this->GetOutputExtension((*i)->GetSourceExtension().c_str()));
{
std::string outExt =
m_GlobalGenerator->GetLanguageOutputExtensionFromExtension(
(*i)->GetSourceExtension().c_str());
if(outExt.size() && !(*i)->GetPropertyAsBool("EXTERNAL_OBJECT") )
{
fout << "\\\n";
@ -560,8 +546,9 @@ void cmLocalUnixMakefileGenerator::OutputTargetRules(std::ostream& fout)
if(!(*i)->GetPropertyAsBool("HEADER_FILE_ONLY") &&
!(*i)->GetCustomCommand())
{
std::string outExt(
this->GetOutputExtension((*i)->GetSourceExtension().c_str()));
std::string outExt =
m_GlobalGenerator->GetLanguageOutputExtensionFromExtension(
(*i)->GetSourceExtension().c_str());
if(outExt.size() && (*i)->GetPropertyAsBool("EXTERNAL_OBJECT") )
{
fout << "\\\n";
@ -577,7 +564,9 @@ void cmLocalUnixMakefileGenerator::OutputTargetRules(std::ostream& fout)
if(!(*i)->GetPropertyAsBool("HEADER_FILE_ONLY") &&
!(*i)->GetCustomCommand())
{
std::string outExt(this->GetOutputExtension((*i)->GetSourceExtension().c_str()));
std::string outExt =
m_GlobalGenerator->GetLanguageOutputExtensionFromExtension(
(*i)->GetSourceExtension().c_str());
if(outExt.size() && !(*i)->GetPropertyAsBool("EXTERNAL_OBJECT") )
{
std::string ofname = (*i)->GetSourceName() + outExt;
@ -594,7 +583,9 @@ void cmLocalUnixMakefileGenerator::OutputTargetRules(std::ostream& fout)
if(!(*i)->GetPropertyAsBool("HEADER_FILE_ONLY") &&
!(*i)->GetCustomCommand())
{
std::string outExt(this->GetOutputExtension((*i)->GetSourceExtension().c_str()));
std::string outExt =
m_GlobalGenerator->GetLanguageOutputExtensionFromExtension(
(*i)->GetSourceExtension().c_str());
if(outExt.size() && (*i)->GetPropertyAsBool("EXTERNAL_OBJECT") )
{
fout << "\\\n\"" << this->ConvertToMakeTarget(ConvertToRelativeOutputPath((*i)->GetFullPath().c_str()).c_str()) << "\" ";
@ -702,20 +693,13 @@ void cmLocalUnixMakefileGenerator::OutputLinkLibraries(std::ostream& fout,
std::string buildType = m_Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
buildType = cmSystemTools::UpperCase(buildType);
bool cxx = tgt.HasCxx();
if(!cxx )
{
// if linking a c executable use the C runtime flag as cc
// may not be the same program that creates shared libaries
// and may have different flags
runtimeFlag = m_Makefile->GetSafeDefinition("CMAKE_SHARED_LIBRARY_RUNTIME_FLAG");
runtimeSep = m_Makefile->GetSafeDefinition("CMAKE_SHARED_LIBRARY_RUNTIME_FLAG_SEP");
}
else
{
runtimeFlag = m_Makefile->GetSafeDefinition("CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG");
runtimeSep = m_Makefile->GetSafeDefinition("CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG_SEP");
}
const char* linkLanguage = tgt.GetLinkerLanguage(this->GetGlobalGenerator());
std::string runTimeFlagVar = "CMAKE_SHARED_LIBRARY_RUNTIME_";
runTimeFlagVar += linkLanguage;
runTimeFlagVar += "_FLAG";
std::string runTimeFlagSepVar = runTimeFlagVar + "_SEP";
runtimeFlag = m_Makefile->GetSafeDefinition(runTimeFlagVar.c_str());
runtimeSep = m_Makefile->GetSafeDefinition(runTimeFlagSepVar.c_str());
// concatenate all paths or no?
bool runtimeConcatenate = ( runtimeSep!="" );
@ -733,16 +717,12 @@ void cmLocalUnixMakefileGenerator::OutputLinkLibraries(std::ostream& fout,
std::string linkLibs;
// Flags to link an executable to shared libraries.
std::string linkFlagsVar = "CMAKE_SHARED_LIBRARY_LINK_";
linkFlagsVar += linkLanguage;
linkFlagsVar += "_FLAGS";
if( tgt.GetType() == cmTarget::EXECUTABLE )
{
if(cxx)
{
linkLibs = m_Makefile->GetSafeDefinition("CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS");
}
else
{
linkLibs = m_Makefile->GetSafeDefinition("CMAKE_SHARED_LIBRARY_LINK_FLAGS");
}
linkLibs = m_Makefile->GetSafeDefinition(linkFlagsVar.c_str());
linkLibs += " ";
}
@ -832,7 +812,6 @@ void cmLocalUnixMakefileGenerator::OutputLinkLibraries(std::ostream& fout,
// then add the lib prefix back into the name
if(m_IgnoreLibPrefix)
{
std::cout << "m_IgnoreLibPrefix\n";
file = "lib" + file;
}
librariesLinked += file;
@ -986,35 +965,30 @@ std::string cmLocalUnixMakefileGenerator::CreatePostBuildRules(
struct RuleVariables
{
const char* replace;
const char* lookup;
const char* variable;
};
static RuleVariables ruleReplaceVars[] =
// List of variables that are replaced when
// rules are expanced. These variables are
// replaced in the form <var> with GetSafeDefinition(var).
// ${LANG} is replaced in the variable first with all enabled
// languages.
static const char* ruleReplaceVars[] =
{
{"<CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS>", "CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS"},
{"<CMAKE_SHARED_MODULE_CREATE_CXX_FLAGS>", "CMAKE_SHARED_MODULE_CREATE_CXX_FLAGS"},
{"<CMAKE_SHARED_MODULE_CREATE_FORTAN_FLAGS>", "CMAKE_SHARED_MODULE_CREATE_FORTAN_FLAGS"},
{"<CMAKE_SHARED_MODULE_C_FLAGS>", "CMAKE_SHARED_MODULE_C_FLAGS"},
{"<CMAKE_SHARED_MODULE_Fortran_FLAGS>", "CMAKE_SHARED_MODULE_Fortran_FLAGS"},
{"<CMAKE_SHARED_MODULE_CXX_FLAGS>", "CMAKE_SHARED_MODULE_CXX_FLAGS"},
{"<CMAKE_SHARED_LIBRARY_C_FLAGS>", "CMAKE_SHARED_LIBRARY_C_FLAGS"},
{"<CMAKE_SHARED_LIBRARY_Fortran_FLAGS>", "CMAKE_SHARED_LIBRARY_Fortran_FLAGS"},
{"<CMAKE_SHARED_LIBRARY_CXX_FLAGS>", "CMAKE_SHARED_LIBRARY_CXX_FLAGS"},
{"<CMAKE_CXX_LINK_FLAGS>", "CMAKE_CXX_LINK_FLAGS"},
{"<CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS>", "CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS"},
{"<CMAKE_SHARED_LIBRARY_CREATE_Fortran_FLAGS>", "CMAKE_SHARED_LIBRARY_CREATE_Fortran_FLAGS"},
{"<CMAKE_SHARED_MODULE_CREATE_C_FLAGS>", "CMAKE_SHARED_MODULE_CREATE_C_FLAGS"},
{"<CMAKE_SHARED_LIBRARY_SONAME_C_FLAG>", "CMAKE_SHARED_LIBRARY_SONAME_C_FLAG"},
{"<CMAKE_SHARED_LIBRARY_SONAME_Fortran_FLAG>", "CMAKE_SHARED_LIBRARY_SONAME_Fortran_FLAG"},
{"<CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG>", "CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG"},
{"<CMAKE_C_LINK_FLAGS>", "CMAKE_C_LINK_FLAGS"},
{"<CMAKE_Fortran_LINK_FLAGS>", "CMAKE_Fortran_LINK_FLAGS"},
{"<CMAKE_AR>", "CMAKE_AR"},
{"<CMAKE_RANLIB>", "CMAKE_RANLIB"},
{0, 0}
"CMAKE_SHARED_LIBRARY_CREATE_${LANG}_FLAGS",
"CMAKE_SHARED_MODULE_CREATE_${LANG}_FLAGS",
"CMAKE_SHARED_MODULE_${LANG}_FLAGS",
"CMAKE_SHARED_LIBRARY_${LANG}_FLAGS",
"CMAKE_${LANG}_LINK_FLAGS",
"CMAKE_SHARED_LIBRARY_SONAME_${LANG}_FLAG",
"CMAKE_${LANG}_ARCHIVE",
"CMAKE_${LANG}_COMPILER",
"CMAKE_AR",
"CMAKE_CURRENT_SOURCE_DIR",
"CMAKE_CURRENT_BINARY_DIR",
"CMAKE_RANLIB",
0
};
@ -1033,15 +1007,9 @@ cmLocalUnixMakefileGenerator::ExpandRuleVariables(std::string& s,
const char* targetSOName,
const char* linkFlags)
{
std::string cxxcompiler = this->ConvertToOutputForExisting(
m_Makefile->GetSafeDefinition("CMAKE_CXX_COMPILER"));
std::string ccompiler = this->ConvertToOutputForExisting(
m_Makefile->GetSafeDefinition("CMAKE_C_COMPILER"));
std::string fcompiler = this->ConvertToOutputForExisting(
m_Makefile->GetSafeDefinition("CMAKE_Fortran_COMPILER"));
cmSystemTools::ReplaceString(s, "<CMAKE_Fortran_COMPILER>", fcompiler.c_str());
cmSystemTools::ReplaceString(s, "<CMAKE_CXX_COMPILER>", cxxcompiler.c_str());
cmSystemTools::ReplaceString(s, "<CMAKE_C_COMPILER>", ccompiler.c_str());
std::vector<std::string> enabledLanguages;
m_GlobalGenerator->GetEnabledLanguages(enabledLanguages);
if(linkFlags)
{
cmSystemTools::ReplaceString(s, "<LINK_FLAGS>", linkFlags);
@ -1111,13 +1079,31 @@ cmLocalUnixMakefileGenerator::ExpandRuleVariables(std::string& s,
cmSystemTools::ReplaceString(s, "<LINK_LIBRARIES>", linkLibs);
}
RuleVariables* rv = ruleReplaceVars;
while(rv->replace)
// loop over language specific replace variables
int pos = 0;
while(ruleReplaceVars[pos])
{
cmSystemTools::ReplaceString(s, rv->replace,
m_Makefile->GetSafeDefinition(rv->lookup));
rv++;
}
std::string replace = "<";
replace += ruleReplaceVars[pos];
replace += ">";
std::string replaceWith = ruleReplaceVars[pos];
for(std::vector<std::string>::iterator i = enabledLanguages.begin();
i != enabledLanguages.end(); ++i)
{
std::string actualReplace = replace;
cmSystemTools::ReplaceString(actualReplace, "${LANG}", i->c_str());
std::string actualReplaceWith = replaceWith;
cmSystemTools::ReplaceString(actualReplaceWith, "${LANG}", i->c_str());
std::string replace = m_Makefile->GetSafeDefinition(actualReplaceWith.c_str());
// if the variable is not a FLAG then treat it like a path
if(actualReplaceWith.find("_FLAG") == actualReplaceWith.npos)
{
replace = this->ConvertToOutputForExisting(replace.c_str());
}
cmSystemTools::ReplaceString(s, actualReplace.c_str(), replace.c_str());
}
pos++;
}
}
@ -1176,8 +1162,10 @@ void cmLocalUnixMakefileGenerator::OutputLibraryRule(std::ostream& fout,
}
// get the objects that are used to link this library
std::string objs = "$(" + this->CreateMakeVariable(name, "_SRC_OBJS") + ") $(" + this->CreateMakeVariable(name, "_EXTERNAL_OBJS") + ") ";
std::string objsQuoted = "$(" + this->CreateMakeVariable(name, "_SRC_OBJS_QUOTED") + ") $(" + this->CreateMakeVariable(name, "_EXTERNAL_OBJS_QUOTED") + ") ";
std::string objs = "$(" + this->CreateMakeVariable(name, "_SRC_OBJS")
+ ") $(" + this->CreateMakeVariable(name, "_EXTERNAL_OBJS") + ") ";
std::string objsQuoted = "$(" + this->CreateMakeVariable(name, "_SRC_OBJS_QUOTED")
+ ") $(" + this->CreateMakeVariable(name, "_EXTERNAL_OBJS_QUOTED") + ") ";
// create a variable with the objects that this library depends on
std::string depend =
objs + " $(" + this->CreateMakeVariable(name, "_DEPEND_LIBS") + ")";
@ -1289,23 +1277,10 @@ void cmLocalUnixMakefileGenerator::OutputSharedLibraryRule(std::ostream& fout,
const char* name,
const cmTarget &t)
{
const char* createRule;
if(t.HasCxx())
{
createRule = "CMAKE_CXX_CREATE_SHARED_LIBRARY";
}
else
{
if(t.HasFortran())
{
createRule = "CMAKE_Fortran_CREATE_SHARED_LIBRARY";
}
else
{
createRule = "CMAKE_C_CREATE_SHARED_LIBRARY";
}
}
const char* linkLanguage = t.GetLinkerLanguage(this->GetGlobalGenerator());
std::string createRule = "CMAKE_";
createRule += linkLanguage;
createRule += "_CREATE_SHARED_LIBRARY";
std::string buildType = m_Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
buildType = cmSystemTools::UpperCase(buildType);
std::string linkFlags = m_Makefile->GetSafeDefinition("CMAKE_SHARED_LINKER_FLAGS");
@ -1339,7 +1314,7 @@ void cmLocalUnixMakefileGenerator::OutputSharedLibraryRule(std::ostream& fout,
linkFlags += " ";
}
this->OutputLibraryRule(fout, name, t,
createRule,
createRule.c_str(),
"shared library",
linkFlags.c_str());
}
@ -1348,23 +1323,10 @@ void cmLocalUnixMakefileGenerator::OutputModuleLibraryRule(std::ostream& fout,
const char* name,
const cmTarget &t)
{
const char* createRule;
if(t.HasCxx())
{
createRule = "CMAKE_CXX_CREATE_SHARED_MODULE";
}
else
{
if(t.HasFortran())
{
createRule = "CMAKE_Fortran_CREATE_SHARED_MODULE";
}
else
{
createRule = "CMAKE_C_CREATE_SHARED_MODULE";
}
}
const char* linkLanguage = t.GetLinkerLanguage(this->GetGlobalGenerator());
std::string createRule = "CMAKE_";
createRule += linkLanguage;
createRule += "_CREATE_SHARED_MODULE";
std::string buildType = m_Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
buildType = cmSystemTools::UpperCase(buildType);
std::string linkFlags = m_Makefile->GetSafeDefinition("CMAKE_MODULE_LINKER_FLAGS");
@ -1383,7 +1345,7 @@ void cmLocalUnixMakefileGenerator::OutputModuleLibraryRule(std::ostream& fout,
linkFlags += " ";
}
this->OutputLibraryRule(fout, name, t,
createRule,
createRule.c_str(),
"shared module",
linkFlags.c_str());
}
@ -1393,23 +1355,10 @@ void cmLocalUnixMakefileGenerator::OutputStaticLibraryRule(std::ostream& fout,
const char* name,
const cmTarget &t)
{
const char* createRule;
if(t.HasCxx())
{
createRule = "CMAKE_CXX_CREATE_STATIC_LIBRARY";
}
else
{
if(t.HasFortran())
{
createRule = "CMAKE_Fortran_CREATE_STATIC_LIBRARY";
}
else
{
createRule = "CMAKE_C_CREATE_STATIC_LIBRARY";
}
}
const char* linkLanguage = t.GetLinkerLanguage(this->GetGlobalGenerator());
std::string createRule = "CMAKE_";
createRule += linkLanguage;
createRule += "_CREATE_STATIC_LIBRARY";
std::string linkFlags;
const char* targetLinkFlags = t.GetProperty("STATIC_LIBRARY_FLAGS");
if(targetLinkFlags)
@ -1418,7 +1367,7 @@ void cmLocalUnixMakefileGenerator::OutputStaticLibraryRule(std::ostream& fout,
linkFlags += " ";
}
this->OutputLibraryRule(fout, name, t,
createRule,
createRule.c_str(),
"static library",
linkFlags.c_str());
@ -1486,34 +1435,23 @@ void cmLocalUnixMakefileGenerator::OutputExecutableRule(std::ostream& fout,
linkFlags += m_Makefile->GetSafeDefinition(build.c_str());
linkFlags += " ";
}
const char* linkLanguage = t.GetLinkerLanguage(this->GetGlobalGenerator());
std::string langVar = "CMAKE_";
langVar += linkLanguage;
std::string ruleVar = langVar + "_LINK_EXECUTABLE";
std::string flagsVar = langVar + "_FLAGS";
std::string sharedFlagsVar = "CMAKE_SHARED_LIBRARY_";
sharedFlagsVar += langVar;
sharedFlagsVar += "_FLAGS";
rules.push_back(m_Makefile->GetRequiredDefinition(ruleVar.c_str()));
flags += m_Makefile->GetSafeDefinition(flagsVar.c_str());
flags += " ";
flags += m_Makefile->GetSafeDefinition(sharedFlagsVar.c_str());
flags += " ";
if(t.HasCxx())
{
rules.push_back(m_Makefile->GetRequiredDefinition("CMAKE_CXX_LINK_EXECUTABLE"));
flags += m_Makefile->GetSafeDefinition("CMAKE_CXX_FLAGS");
flags += " ";
flags += m_Makefile->GetSafeDefinition("CMAKE_SHARED_LIBRARY_CXX_FLAGS");
flags += " ";
}
else
{
if(t.HasFortran())
{
rules.push_back(m_Makefile->GetRequiredDefinition("CMAKE_Fortran_LINK_EXECUTABLE"));
flags += m_Makefile->GetSafeDefinition("CMAKE_Fortran_FLAGS");
flags += " ";
flags += m_Makefile->GetSafeDefinition("CMAKE_SHARED_LIBRARY_Fortran_FLAGS");
flags += " ";
}
else
{
rules.push_back(m_Makefile->GetRequiredDefinition("CMAKE_C_LINK_EXECUTABLE"));
flags += m_Makefile->GetSafeDefinition("CMAKE_C_FLAGS");
flags += " ";
flags += m_Makefile->GetSafeDefinition("CMAKE_SHARED_LIBRARY_C_FLAGS");
flags += " ";
}
}
cmOStringStream linklibs;
this->OutputLinkLibraries(linklibs, 0, t);
std::string comment = "executable";
@ -1538,7 +1476,9 @@ void cmLocalUnixMakefileGenerator::OutputExecutableRule(std::ostream& fout,
}
if(cmSystemTools::IsOn(m_Makefile->GetDefinition("BUILD_SHARED_LIBS")))
{
linkFlags += m_Makefile->GetSafeDefinition("CMAKE_SHARED_BUILD_CXX_FLAGS");
std::string sFlagVar = std::string("CMAKE_SHARED_BUILD_") + linkLanguage
+ std::string("_FLAGS");
linkFlags += m_Makefile->GetSafeDefinition(sFlagVar.c_str());
linkFlags += " ";
}
@ -2325,7 +2265,10 @@ bool cmLocalUnixMakefileGenerator::OutputObjectDepends(std::ostream& fout)
dep != (*source)->GetDepends().end(); ++dep)
{
std::string s = (*source)->GetSourceName();
s += this->GetOutputExtension((*source)->GetSourceExtension().c_str());
std::string outExt =
m_GlobalGenerator->GetLanguageOutputExtensionFromExtension(
(*source)->GetSourceExtension().c_str());
s += outExt;
fout << this->ConvertToRelativeOutputPath(s.c_str()) << " : "
<< this->ConvertToRelativeOutputPath(dep->c_str()) << "\n";
ret = true;
@ -2555,8 +2498,17 @@ void cmLocalUnixMakefileGenerator::OutputMakeVariables(std::ostream& fout)
fout << "CMAKE_BINARY_DIR = " <<
this->ConvertToRelativeOutputPath(m_Makefile->GetHomeOutputDirectory())
<< "\n";
// Output Include paths
fout << "INCLUDE_FLAGS = ";
fout << "\n\n";
}
cmStdString& cmLocalUnixMakefileGenerator::GetIncludeFlags(const char* lang)
{
if(m_LanguageToIncludeFlags.count(lang))
{
return m_LanguageToIncludeFlags[lang];
}
// Output Include paths
cmOStringStream includeFlags;
std::vector<std::string>& includes = m_Makefile->GetIncludeDirectories();
std::vector<std::string>::iterator i;
std::map<cmStdString, cmStdString> implicitIncludes;
@ -2592,11 +2544,31 @@ void cmLocalUnixMakefileGenerator::OutputMakeVariables(std::ostream& fout)
includeSourceDir = true;
}
}
std::string flagVar = "CMAKE_INCLUDE_FLAG_";
flagVar += lang;
const char* includeFlag = m_Makefile->GetDefinition(flagVar.c_str());
flagVar = "CMAKE_INCLUDE_FLAG_SEP_";
flagVar += lang;
const char* sep = m_Makefile->GetDefinition(flagVar.c_str());
bool repeatFlag = true; // should the include flag be repeated like ie. -IA -IB
if(!sep)
{
sep = " ";
}
else
{
// if there is a separator then the flag is not repeated but is only given once
// i.e. -classpath a:b:c
repeatFlag = false;
}
bool flagUsed = false;
if(includeSourceDir)
{
fout << "-I"
includeFlags << includeFlag
<< this->ConvertToOutputForExisting(m_Makefile->GetStartDirectory())
<< " ";
<< sep;
flagUsed = true;
}
implicitIncludes["/usr/include"] = "/usr/include";
@ -2619,14 +2591,25 @@ void cmLocalUnixMakefileGenerator::OutputMakeVariables(std::ostream& fout)
// implementations because the wrong headers may be found first.
if(implicitIncludes.find(include) == implicitIncludes.end())
{
fout << "-I" << this->ConvertToOutputForExisting(i->c_str()) << " ";
if(!flagUsed || repeatFlag)
{
includeFlags << includeFlag;
flagUsed = true;
}
includeFlags << this->ConvertToOutputForExisting(i->c_str()) << sep;
}
}
fout << m_Makefile->GetDefineFlags();
fout << "\n\n";
std::string flags = includeFlags.str();
// remove trailing separators
if((sep[0] != ' ') && flags[flags.size()-1] == sep[0])
{
flags[flags.size()-1] = ' ';
}
flags += m_Makefile->GetDefineFlags();
m_LanguageToIncludeFlags[lang] = flags;
return m_LanguageToIncludeFlags[lang];
}
void cmLocalUnixMakefileGenerator::OutputMakeRules(std::ostream& fout)
{
this->OutputMakeRule(fout,
@ -2827,13 +2810,12 @@ OutputBuildObjectFromSource(std::ostream& fout,
return;
}
std::string comment = "object file";
std::string objectFile = std::string(shortName) +
this->GetOutputExtension(source.GetSourceExtension().c_str());
std::string outputExt =
m_GlobalGenerator->GetLanguageOutputExtensionFromExtension(
source.GetSourceExtension().c_str());
std::string objectFile = std::string(shortName) + outputExt;
objectFile = this->CreateSafeUniqueObjectFileName(objectFile.c_str());
objectFile = this->ConvertToRelativeOutputPath(objectFile.c_str());
cmSystemTools::FileFormat format =
cmSystemTools::GetFileFormat(source.GetSourceExtension().c_str());
std::vector<std::string> rules;
std::string flags;
if(extraCompileFlags)
@ -2848,6 +2830,19 @@ OutputBuildObjectFromSource(std::ostream& fout,
const char* lang =
m_GlobalGenerator->GetLanguageFromExtension(source.GetSourceExtension().c_str());
// for now if the lang is defined add the rules and flags for it
std::string comment = outputExt;
comment += " file";
if(lang)
{
comment += " from ";
comment += lang;
comment += ": ";
if(comment.size() < 18)
{
comment.resize(18, ' ');
}
}
if(lang)
{
std::string varString = "CMAKE_";
@ -2883,44 +2878,17 @@ OutputBuildObjectFromSource(std::ostream& fout,
flags += " ";
}
}
// the language is not defined, fall back on old stuff
else
{
switch(format)
{
// if the language is not defined and should not be ignored,
// then produce an error
if(!m_GlobalGenerator->IgnoreFile(source.GetSourceExtension().c_str()))
{
// these are all handled by the if(lang) step now
case cmSystemTools::C_FILE_FORMAT:
case cmSystemTools::CXX_FILE_FORMAT:
case cmSystemTools::FORTRAN_FILE_FORMAT:
break;
case cmSystemTools::HEADER_FILE_FORMAT:
return;
case cmSystemTools::DEFINITION_FILE_FORMAT:
return;
case cmSystemTools::OBJECT_FILE_FORMAT:
return;
case cmSystemTools::RESOURCE_FILE_FORMAT:
{
// 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::UNKNOWN_FILE_FORMAT:
cmSystemTools::Error("Unexpected file type ",
sourceFile.c_str());
break;
}
cmSystemTools::Error("Unexpected file type ",
sourceFile.c_str());
}
}
flags += "$(INCLUDE_FLAGS) ";
flags += this->GetIncludeFlags(lang);
// expand multi-command semi-colon separated lists
// of commands into separate commands
std::vector<std::string> commands;
@ -2964,8 +2932,7 @@ OutputBuildObjectFromSource(std::ostream& fout,
void cmLocalUnixMakefileGenerator::OutputSourceObjectBuildRules(std::ostream& fout)
{
fout << "# Rules to build " << this->GetOutputExtension("")
<< " files from their sources:\n";
fout << "# Rules to build source files :\n\n";
std::set<std::string> rules;

View File

@ -88,6 +88,7 @@ public:
void SetPassMakeflags(bool s){m_PassMakeflags = s;}
protected:
void AddDependenciesToSourceFile(cmDependInformation const*info,
cmSourceFile *i,
std::set<cmDependInformation const*> *visited);
@ -198,7 +199,6 @@ 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);
std::string CreatePreBuildRules(const cmTarget &target,
const char* targetName);
std::string CreatePreLinkRules(const cmTarget &target,
@ -239,12 +239,13 @@ protected:
*/
std::string& CreateSafeUniqueObjectFileName(const char* sin);
///! final processing for a path to be put in a makefile
cmStdString& GetIncludeFlags(const char* lang);
protected:
int m_MakefileVariableSize;
std::map<cmStdString, cmStdString> m_MakeVariableMap;
std::map<cmStdString, cmStdString> m_ShortMakeVariableMap;
std::map<cmStdString, cmStdString> m_UniqueObjectNamesMap;
std::map<cmStdString, cmStdString> m_LanguageToIncludeFlags;
bool m_IgnoreLibPrefix;
std::string m_IncludeDirective;
std::string m_MakeSilentFlag;

View File

@ -340,8 +340,9 @@ void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout,
{
compileFlags = cflags;
}
if(cmSystemTools::GetFileFormat((*sf)->GetSourceExtension().c_str())
== cmSystemTools::CXX_FILE_FORMAT)
const char* lang =
m_GlobalGenerator->GetLanguageFromExtension((*sf)->GetSourceExtension().c_str());
if(strcmp(lang, "CXX") == 0)
{
// force a C++ file type
compileFlags += " /TP ";
@ -1058,33 +1059,29 @@ void cmLocalVisualStudio6Generator::WriteDSPHeader(std::ostream& fout, const cha
std::string flagsDebug = " ";
std::string flagsDebugRel = " ";
// if CXX is on and the target contains cxx code then add the cxx flags
if ( gen->GetLanguageEnabled("CXX") && target.HasCxx() )
{
flagsRelease = m_Makefile->GetRequiredDefinition("CMAKE_CXX_FLAGS_RELEASE");
flagsRelease += " -DCMAKE_INTDIR=\\\"Release\\\" ";
flagsMinSize = m_Makefile->GetRequiredDefinition("CMAKE_CXX_FLAGS_MINSIZEREL");
flagsMinSize += " -DCMAKE_INTDIR=\\\"MinSizeRel\\\" ";
flagsDebug = m_Makefile->GetRequiredDefinition("CMAKE_CXX_FLAGS_DEBUG");
flagsDebug += " -DCMAKE_INTDIR=\\\"Debug\\\" ";
flagsDebugRel = m_Makefile->GetRequiredDefinition("CMAKE_CXX_FLAGS_RELWITHDEBINFO");
flagsDebugRel += " -DCMAKE_INTDIR=\\\"RelWithDebInfo\\\" ";
flags = " ";
flags = m_Makefile->GetRequiredDefinition("CMAKE_CXX_FLAGS");
}
// if C and the target is not CXX
else if(gen->GetLanguageEnabled("C") && !target.HasCxx())
{
flagsRelease += m_Makefile->GetRequiredDefinition("CMAKE_C_FLAGS_RELEASE");
flagsRelease += " -DCMAKE_INTDIR=\\\"Release\\\"";
flagsMinSize += m_Makefile->GetRequiredDefinition("CMAKE_C_FLAGS_MINSIZEREL");
flagsMinSize += " -DCMAKE_INTDIR=\\\"MinSizeRel\\\"";
flagsDebug += m_Makefile->GetRequiredDefinition("CMAKE_C_FLAGS_DEBUG");
flagsDebug += " -DCMAKE_INTDIR=\\\"Debug\\\"";
flagsDebugRel += m_Makefile->GetRequiredDefinition("CMAKE_C_FLAGS_RELWITHDEBINFO");
flagsDebugRel += " -DCMAKE_INTDIR=\\\"RelWithDebInfo\\\"";
flags = " ";
flags = m_Makefile->GetRequiredDefinition("CMAKE_C_FLAGS");
}
std::string baseFlagVar = "CMAKE_";
const char* linkLanguage = target.GetLinkerLanguage(this->GetGlobalGenerator());
baseFlagVar += "CMAKE_";
baseFlagVar += linkLanguage;
baseFlagVar += "_FLAGS";
flags = m_Makefile->GetRequiredDefinition(baseFlagVar.c_str());
std::string flagVar = baseFlagVar + "_RELEASE";
flagsRelease = m_Makefile->GetRequiredDefinition(flagVar.c_str());
flagsRelease += " -DCMAKE_INTDIR=\\\"Release\\\" ";
flagVar = baseFlagVar + "_MINSIZEREL";
flagsMinSize = m_Makefile->GetRequiredDefinition(flagVar.c_str());
flagsMinSize += " -DCMAKE_INTDIR=\\\"MinSizeRel\\\" ";
flagVar = baseFlagVar + "_DEBUG";
flagsDebug = m_Makefile->GetRequiredDefinition(flagVar.c_str());
flagsDebug += " -DCMAKE_INTDIR=\\\"Debug\\\" ";
flagVar = baseFlagVar + "_RELWITHDEBINFO";
flagsDebugRel = m_Makefile->GetRequiredDefinition(flagVar.c_str());
flagsDebugRel += " -DCMAKE_INTDIR=\\\"RelWithDebInfo\\\" ";
// if unicode is not found, then add -D_MBCS
std::string defs = m_Makefile->GetDefineFlags();
if(flags.find("D_UNICODE") == flags.npos &&
@ -1097,7 +1094,6 @@ void cmLocalVisualStudio6Generator::WriteDSPHeader(std::ostream& fout, const cha
// There are not separate CXX and C template files, so we use the same
// variable names. The previous code sets up flags* variables to contain
// the correct C or CXX flags
cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS_RELEASE", flagsRelease.c_str());
cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS_MINSIZEREL", flagsMinSize.c_str());
cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS_DEBUG", flagsDebug.c_str());
cmSystemTools::ReplaceString(line,"CMAKE_CXX_FLAGS_RELWITHDEBINFO", flagsDebugRel.c_str());

View File

@ -321,24 +321,27 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
std::string flagsRelease = " ";
std::string flagsMinSize = " ";
std::string flagsDebug = " ";
std::string flagsDebugRel = " ";
if(target.HasCxx())
std::string flagsDebugRel = " ";
if(strcmp(configType, "10") != 0)
{
flags = m_Makefile->GetRequiredDefinition("CMAKE_CXX_FLAGS");
flagsRelease += m_Makefile->GetRequiredDefinition("CMAKE_CXX_FLAGS_RELEASE");
flagsMinSize += m_Makefile->GetRequiredDefinition("CMAKE_CXX_FLAGS_MINSIZEREL");
flagsDebug += m_Makefile->GetRequiredDefinition("CMAKE_CXX_FLAGS_DEBUG");
flagsDebugRel += m_Makefile->GetRequiredDefinition("CMAKE_CXX_FLAGS_RELWITHDEBINFO");
}
else
{
flags = m_Makefile->GetRequiredDefinition("CMAKE_C_FLAGS");
flagsRelease += m_Makefile->GetRequiredDefinition("CMAKE_C_FLAGS_RELEASE");
flagsMinSize += m_Makefile->GetRequiredDefinition("CMAKE_C_FLAGS_MINSIZEREL");
flagsDebug += m_Makefile->GetRequiredDefinition("CMAKE_C_FLAGS_DEBUG");
flagsDebugRel += m_Makefile->GetRequiredDefinition("CMAKE_C_FLAGS_RELWITHDEBINFO");
}
const char* linkLanguage = target.GetLinkerLanguage(this->GetGlobalGenerator());
std::string baseFlagVar = "CMAKE_";
baseFlagVar += linkLanguage;
baseFlagVar += "_FLAGS";
flags = m_Makefile->GetRequiredDefinition(baseFlagVar.c_str());
std::string flagVar = baseFlagVar + "_RELEASE";
flagsRelease += m_Makefile->GetRequiredDefinition(flagVar.c_str());
flagVar = baseFlagVar + "_MINSIZEREL";
flagsMinSize += m_Makefile->GetRequiredDefinition(flagVar.c_str());
flagVar = baseFlagVar + "_DEBUG";
flagsDebug += m_Makefile->GetRequiredDefinition(flagVar.c_str());
flagVar = baseFlagVar + "_RELWITHDEBINFO";
flagsDebugRel += m_Makefile->GetRequiredDefinition(flagVar.c_str());
}
std::string programDatabase;
const char* pre = "WIN32,_DEBUG,_WINDOWS";
@ -574,6 +577,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
}
case cmTarget::SHARED_LIBRARY:
case cmTarget::MODULE_LIBRARY:
{
fout << "\t\t\t<Tool\n"
<< "\t\t\t\tName=\"VCLinkerTool\"\n"
<< "\t\t\t\tAdditionalOptions=\"/MACHINE:I386";
@ -620,10 +624,14 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
{
fout << "\t\t\t\tGenerateDebugInformation=\"TRUE\"\n";
}
if(target.HasCxx())
const char* linkLanguage = target.GetLinkerLanguage(this->GetGlobalGenerator());
std::string stackVar = "CMAKE_";
stackVar += linkLanguage;
stackVar += "_STACK_SIZE";
const char* stackVal = m_Makefile->GetDefinition(stackVar.c_str());
if(stackVal)
{
fout << "\t\t\t\tStackReserveSize=\""
<< m_Makefile->GetRequiredDefinition("CMAKE_CXX_STACK_SIZE") << "\"\n";
fout << "\t\t\t\tStackReserveSize=\"" << stackVal << "\"\n";
}
temp = m_LibraryOutputPath;
temp += configName;
@ -632,9 +640,11 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
temp += debugPostfix;
temp += ".lib";
fout << "\t\t\t\tImportLibrary=\"" << this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"/>\n";
}
break;
case cmTarget::EXECUTABLE:
{
fout << "\t\t\t<Tool\n"
<< "\t\t\t\tName=\"VCLinkerTool\"\n"
<< "\t\t\t\tAdditionalOptions=\"/MACHINE:I386";
@ -682,14 +692,19 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
else
{
fout << "\t\t\t\tSubSystem=\"1\"\n";
}
if(target.HasCxx())
}
const char* linkLanguage = target.GetLinkerLanguage(this->GetGlobalGenerator());
std::string stackVar = "CMAKE_";
stackVar += linkLanguage;
stackVar += "_STACK_SIZE";
const char* stackVal = m_Makefile->GetDefinition(stackVar.c_str());
if(stackVal)
{
fout << "\t\t\t\tStackReserveSize=\""
<< m_Makefile->GetRequiredDefinition("CMAKE_CXX_STACK_SIZE") << "\"";
fout << "\t\t\t\tStackReserveSize=\"" << stackVal << "\"";
}
fout << "/>\n";
break;
}
case cmTarget::UTILITY:
break;
}
@ -922,8 +937,9 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout,
{
compileFlags = cflags;
}
if(cmSystemTools::GetFileFormat((*sf)->GetSourceExtension().c_str())
== cmSystemTools::CXX_FILE_FORMAT)
const char* lang =
m_GlobalGenerator->GetLanguageFromExtension((*sf)->GetSourceExtension().c_str());
if(lang && strcmp(lang, "CXX") == 0)
{
// force a C++ file type
compileFlags += " /TP ";

View File

@ -1028,23 +1028,22 @@ void cmMakefile::AddLibrary(const char* lname, int shared,
switch (shared)
{
case 0:
target.SetType(cmTarget::STATIC_LIBRARY);
target.SetType(cmTarget::STATIC_LIBRARY, lname);
break;
case 1:
target.SetType(cmTarget::SHARED_LIBRARY);
target.SetType(cmTarget::SHARED_LIBRARY, lname);
break;
case 2:
target.SetType(cmTarget::MODULE_LIBRARY);
target.SetType(cmTarget::MODULE_LIBRARY, lname);
break;
default:
target.SetType(cmTarget::STATIC_LIBRARY);
target.SetType(cmTarget::STATIC_LIBRARY, lname);
}
// Clear its dependencies. Otherwise, dependencies might persist
// over changes in CMakeLists.txt, making the information stale and
// hence useless.
target.ClearDependencyInformation( *this, lname );
target.SetInAll(true);
target.GetSourceLists() = srcs;
this->AddGlobalLinkInformation(lname, target);
@ -1095,7 +1094,7 @@ cmTarget* cmMakefile::AddExecutable(const char *exeName,
const std::vector<std::string> &srcs)
{
cmTarget target;
target.SetType(cmTarget::EXECUTABLE);
target.SetType(cmTarget::EXECUTABLE, exeName);
target.SetInAll(true);
target.GetSourceLists() = srcs;
this->AddGlobalLinkInformation(exeName, target);
@ -1132,7 +1131,7 @@ void cmMakefile::AddUtilityCommand(const char* utilityName,
const std::vector<std::string> &out)
{
cmTarget target;
target.SetType(cmTarget::UTILITY);
target.SetType(cmTarget::UTILITY, utilityName);
target.SetInAll(all);
if (out.size() > 1)
{

View File

@ -51,6 +51,8 @@ bool cmProjectCommand::InitialPass(std::vector<std::string> const& args)
std::vector<std::string> languages;
if(args.size() > 1)
{
bool hasCXX = false;
bool hasC = false;
for(size_t i =1; i < args.size(); ++i)
{
languages.push_back(args[i]);

View File

@ -17,15 +17,16 @@
#include "cmTarget.h"
#include "cmMakefile.h"
#include "cmSourceFile.h"
#include "cmGlobalGenerator.h"
#include <map>
#include <set>
#include <queue>
#include <stdlib.h> // required for atof
void cmTarget::SetType(TargetType type)
void cmTarget::SetType(TargetType type, const char* name)
{
m_Name = name;
// only add dependency information for library targets
m_TargetType = type;
if(m_TargetType >= STATIC_LIBRARY && m_TargetType <= MODULE_LIBRARY) {
@ -419,46 +420,6 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf,
}
bool cmTarget::HasCxx() const
{
if(this->GetProperty("HAS_CXX"))
{
return true;
}
for(std::vector<cmSourceFile*>::const_iterator i = m_SourceFiles.begin();
i != m_SourceFiles.end(); ++i)
{
if(cmSystemTools::GetFileFormat((*i)->GetSourceExtension().c_str())
== cmSystemTools::CXX_FILE_FORMAT)
{
return true;
}
}
return false;
}
bool cmTarget::HasFortran() const
{
if(this->GetProperty("HAS_FORTRAN"))
{
return true;
}
for(std::vector<cmSourceFile*>::const_iterator i = m_SourceFiles.begin();
i != m_SourceFiles.end(); ++i)
{
if(cmSystemTools::GetFileFormat((*i)->GetSourceExtension().c_str())
== cmSystemTools::FORTRAN_FILE_FORMAT)
{
return true;
}
}
return false;
}
void
cmTarget::AnalyzeLibDependencies( const cmMakefile& mf )
{
@ -783,3 +744,68 @@ bool cmTarget::GetPropertyAsBool(const char* prop) const
}
return false;
}
const char* cmTarget::GetLinkerLanguage(cmGlobalGenerator* gg) const
{
if(this->GetProperty("HAS_CXX"))
{
const_cast<cmTarget*>(this)->SetProperty("LINKER_LANGUAGE", "CXX");
}
const char* linkerLang = this->GetProperty("LINKER_LANGUAGE");
if(linkerLang)
{
return linkerLang;
}
std::set<cmStdString> languages;
for(std::vector<cmSourceFile*>::const_iterator i = m_SourceFiles.begin();
i != m_SourceFiles.end(); ++i)
{
const char* lang =
gg->GetLanguageFromExtension((*i)->GetSourceExtension().c_str());
if(lang)
{
languages.insert(lang);
}
}
if(languages.size() == 0)
{
std::string m = "Error Target: ";
m += m_Name + " contains no source files with an enabled languages.";
cmSystemTools::Error(m.c_str());
return "(NullLanguage)";
}
if(languages.size() == 1)
{
const_cast<cmTarget*>(this)->SetProperty("LINKER_LANGUAGE", languages.begin()->c_str());
return this->GetProperty("LINKER_LANGUAGE");
}
const char* prefLang = 0;
for(std::set<cmStdString>::const_iterator s = languages.begin();
s != languages.end(); ++s)
{
const char* lpref = gg->GetLinkerPreference(s->c_str());
if(lpref[0] == 'P')
{
if(prefLang && !(*s == prefLang))
{
std::string m = "Error Target: ";
m += m_Name + " Contains more than one Prefered language: ";
m += *s;
m += " and ";
m += prefLang;
m += "\nYou must set the LINKER_LANGUAGE property for this target.";
cmSystemTools::Error(m.c_str());
}
else
{
prefLang = s->c_str();
}
}
}
if(!prefLang)
{
prefLang = languages.begin()->c_str();
}
const_cast<cmTarget*>(this)->SetProperty("LINKER_LANGUAGE", languages.begin()->c_str());
return this->GetProperty("LINKER_LANGUAGE");
}

View File

@ -19,6 +19,7 @@
#include "cmCustomCommand.h"
class cmSourceFile;
class cmGlobalGenerator;
/** \class cmTarget
* \brief Represent a library or executable target loaded from a makefile.
@ -46,7 +47,10 @@ public:
/**
* Set the target type
*/
void SetType(TargetType f);
void SetType(TargetType f, const char* name);
///! Set/Get the name of the target
const char* GetName() const {return m_Name.c_str();}
/**
* Indicate whether the target is part of the all target
@ -85,11 +89,6 @@ public:
{return m_SourceFiles;}
std::vector<cmSourceFile*> &GetSourceFiles() {return m_SourceFiles;}
///! does this target have a cxx file in it
bool HasCxx() const;
///! does this target have a fortran file in it
bool HasFortran() const;
/**
* Get the list of the source files used by this target
*/
@ -156,6 +155,8 @@ public:
*/
void TraceVSDependencies(std::string projName, cmMakefile *mf);
///! Return the prefered linker language for this target
const char* GetLinkerLanguage(cmGlobalGenerator*) const;
private:
/**
* A list of direct dependencies. Use in conjunction with DependencyMap.
@ -210,7 +211,9 @@ private:
void GatherDependencies( const cmMakefile& mf, const std::string& lib,
DependencyMap& dep_map );
private:
std::string m_Name;
std::vector<cmCustomCommand> m_PreBuildCommands;
std::vector<cmCustomCommand> m_PreLinkCommands;
std::vector<cmCustomCommand> m_PostBuildCommands;

View File

@ -17,6 +17,7 @@
#include "cmTryCompileCommand.h"
#include "cmake.h"
#include "cmCacheManager.h"
#include "cmGlobalGenerator.h"
#include "cmListFileCache.h"
#include <cmsys/Directory.hxx>
@ -146,56 +147,38 @@ int cmTryCompileCommand::CoreTryCompileCode(
}
std::string source = argv[2];
cmSystemTools::FileFormat format =
cmSystemTools::GetFileFormat(
cmSystemTools::GetFilenameExtension(source).c_str());
if ( format == cmSystemTools::C_FILE_FORMAT )
const char* lang = mf->GetCMakeInstance()->GetGlobalGenerator()->GetLanguageFromExtension(
cmSystemTools::GetFilenameExtension(source).c_str());
if(lang)
{
fprintf(fout, "PROJECT(CMAKE_TRY_COMPILE C)\n");
}
else if ( format == cmSystemTools::CXX_FILE_FORMAT )
{
fprintf(fout, "PROJECT(CMAKE_TRY_COMPILE C CXX)\n");
}
else if ( format == cmSystemTools::FORTRAN_FILE_FORMAT )
{
fprintf(fout, "PROJECT(CMAKE_TRY_COMPILE Fortran)\n");
fprintf(fout, "PROJECT(CMAKE_TRY_COMPILE %s)\n", lang);
}
else
{
cmSystemTools::Error("Unknown file format for file: ", source.c_str(),
"; TRY_COMPILE only works for C, CXX, and FORTRAN files");
std::vector<std::string> lang;
mf->GetCMakeInstance()->GetGlobalGenerator()->GetEnabledLanguages(lang);
std::string msg = "TRY_COMPILE only works for enabled languages files,"
"\nCurrently enabled languages are:\n";
for(std::vector<std::string>::iterator l = lang.begin();
l != lang.end(); ++l)
{
msg += *l;
msg += " ";
}
cmSystemTools::Error("Unknown file format for file: ", source.c_str(), msg.c_str());
return -1;
}
const char* cflags = mf->GetDefinition("CMAKE_C_FLAGS");
std::string langFlags = "CMAKE_";
langFlags += lang;
langFlags += "_FLAGS";
fprintf(fout, "SET(CMAKE_VERBOSE_MAKEFILE 1)\n");
fprintf(fout, "SET(CMAKE_C_FLAGS \"${CMAKE_C_FLAGS}");
if(cflags)
fprintf(fout, "SET(CMAKE_%s_FLAGS \"${CMAKE_%s_FLAGS}", lang, lang);
const char* flags = mf->GetDefinition(langFlags.c_str());
if(flags)
{
fprintf(fout, " %s ", cflags);
fprintf(fout, " %s ", flags);
}
fprintf(fout, " ${COMPILE_DEFINITIONS}\")\n");
// CXX specific flags
if(format == cmSystemTools::CXX_FILE_FORMAT )
{
const char* cxxflags = mf->GetDefinition("CMAKE_CXX_FLAGS");
fprintf(fout, "SET(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} ");
if(cxxflags)
{
fprintf(fout, " %s ", cxxflags);
}
fprintf(fout, " ${COMPILE_DEFINITIONS}\")\n");
}
if(format == cmSystemTools::FORTRAN_FILE_FORMAT )
{
const char* fflags = mf->GetDefinition("CMAKE_Fortran_FLAGS");
fprintf(fout, "SET(CMAKE_Fortran_FLAGS \"${CMAKE_Fortran_FLAGS} ");
if(fflags)
{
fprintf(fout, " %s ", fflags);
}
fprintf(fout, " ${COMPILE_DEFINITIONS}\")\n");
}
fprintf(fout, "INCLUDE_DIRECTORIES(${INCLUDE_DIRECTORIES})\n");
fprintf(fout, "LINK_DIRECTORIES(${LINK_DIRECTORIES})\n");
// handle any compile flags we need to pass on

View File

@ -33,6 +33,7 @@ bool cmTryRunCommand::InitialPass(std::vector<std::string> const& argv)
// build an arg list for TryCompile and extract the runArgs
std::vector<std::string> tryCompile;
std::string outputVariable;
std::string runArgs;
unsigned int i;
for (i = 1; i < argv.size(); ++i)
@ -51,13 +52,22 @@ bool cmTryRunCommand::InitialPass(std::vector<std::string> const& argv)
{
tryCompile.push_back(argv[i]);
}
}
else
}
else
{
tryCompile.push_back(argv[i]);
if (argv[i] == "OUTPUT_VARIABLE")
{
if ( argv.size() <= (i+1) )
{
cmSystemTools::Error(
"OUTPUT_VARIABLE specified but there is no variable");
return false;
}
outputVariable = argv[i+1];
}
}
}
// do the try compile
int res = cmTryCompileCommand::CoreTryCompileCode(m_Makefile, tryCompile, false);
@ -102,6 +112,18 @@ bool cmTryRunCommand::InitialPass(std::vector<std::string> const& argv)
int timeout = 0;
cmSystemTools::RunSingleCommand(finalCommand.c_str(), &output, &retVal,
0, false, timeout);
if(outputVariable.size())
{
// if the TryCompileCore saved output in this outputVariable then
// prepend that output to this output
const char* compileOutput = m_Makefile->GetDefinition(outputVariable.c_str());
if(compileOutput)
{
output = std::string(compileOutput) + output;
}
m_Makefile->AddDefinition(outputVariable.c_str(), output.c_str());
}
// set the run var
char retChar[1000];
sprintf(retChar,"%i",retVal);

View File

@ -7,6 +7,6 @@ MESSAGE("CMAKE_Fortran_FLAGS = ${CMAKE_Fortran_FLAGS}")
MESSAGE("All cmake variables:")
GET_CMAKE_PROPERTY(res VARIABLES)
FOREACH(var ${res})
MESSAGE("${var}=\"${${var}}\"")
MESSAGE("${var}=\"${${var}}\"\n")
ENDFOREACH(var ${res})
ADD_EXECUTABLE(testf hello.f)

11
Tests/Java/A.java Normal file
View File

@ -0,0 +1,11 @@
class A
{
public A()
{
}
public void printName()
{
System.out.println("A");
}
}

29
Tests/Java/CMakeLists.txt Normal file
View File

@ -0,0 +1,29 @@
PROJECT(hello Java)
SET(OLD_CUSTOM_COMMAND_WAY )
IF(NOT OLD_CUSTOM_COMMAND_WAY)
INCLUDE_DIRECTORIES(${hello_SOURCE_DIR})
INCLUDE_DIRECTORIES(${hello_BINARY_DIR})
ADD_LIBRARY(hello A.java HelloWorld.java)
ENDIF(NOT OLD_CUSTOM_COMMAND_WAY)
IF(OLD_CUSTOM_COMMAND_WAY)
ADD_CUSTOM_COMMAND(
OUTPUT ${hello_BINARY_DIR}/A.class
MAIN_DEPENDENCY ${hello_SOURCE_DIR}/A.java
COMMAND ${CMAKE_Java_COMPILER} ARGS -d ${hello_BINARY_DIR} ${hello_SOURCE_DIR}/A.java)
ADD_CUSTOM_COMMAND(
OUTPUT ${hello_BINARY_DIR}/HelloWorld.class
MAIN_DEPENDENCY ${hello_SOURCE_DIR}/HelloWorld.java
COMMAND ${CMAKE_Java_COMPILER} ARGS -d ${hello_BINARY_DIR} ${hello_SOURCE_DIR}/HelloWorld.java)
ADD_CUSTOM_TARGET(foo.jar ALL
DEPENDS ${hello_BINARY_DIR}/A.class ${hello_BINARY_DIR}/HelloWorld.class)
ADD_CUSTOM_COMMAND( TARGET foo.jar
PRE_BUILD
COMMAND ${CMAKE_COMMAND}
ARGS -E chdir ${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_Java_ARCHIVE}
-cvf foo.jar *.class)
ENDIF(OLD_CUSTOM_COMMAND_WAY)

View File

@ -0,0 +1,11 @@
class HelloWorld
{
public static void main(String args[])
{
A a;
a = new A();
a.printName();
System.out.println("Hello World!");
}
}