From 65e3edea04fdd058719659e99a7a3da3dfb80b25 Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Mon, 8 Apr 2002 13:36:18 -0400 Subject: [PATCH] ENH: use separate vars for creating c++ and c shared libraries and add a test for c libraries --- Source/cmExecProgramCommand.cxx | 2 +- Source/cmUnixMakefileGenerator.cxx | 58 +++++++++++++---- Templates/CCMakeSystemConfig.cmake.in | 2 + Templates/CXXCMakeSystemConfig.cmake.in | 57 +++++++++++++++++ Templates/cconfigure | 64 ++++++++++--------- Templates/cconfigure.in | 15 +++-- Templates/cxxconfigure | 33 ++++++++++ Templates/cxxconfigure.in | 25 ++++++++ Tests/Complex/Executable/CMakeLists.txt | 2 +- Tests/Complex/Executable/complex.cxx | 11 ++++ Tests/Complex/Library/CMakeLists.txt | 2 + Tests/Complex/Library/testConly.c | 6 ++ Tests/Complex/Library/testConly.h | 12 ++++ .../Executable/CMakeLists.txt | 2 +- Tests/ComplexOneConfig/Executable/complex.cxx | 11 ++++ Tests/ComplexOneConfig/Library/CMakeLists.txt | 2 + Tests/ComplexOneConfig/Library/testConly.c | 6 ++ Tests/ComplexOneConfig/Library/testConly.h | 12 ++++ .../Executable/CMakeLists.txt | 2 +- .../Executable/complex.cxx | 11 ++++ .../Library/CMakeLists.txt | 2 + .../ComplexRelativePaths/Library/testConly.c | 6 ++ .../ComplexRelativePaths/Library/testConly.h | 12 ++++ 23 files changed, 301 insertions(+), 54 deletions(-) create mode 100644 Tests/Complex/Library/testConly.c create mode 100644 Tests/Complex/Library/testConly.h create mode 100644 Tests/ComplexOneConfig/Library/testConly.c create mode 100644 Tests/ComplexOneConfig/Library/testConly.h create mode 100644 Tests/ComplexRelativePaths/Library/testConly.c create mode 100644 Tests/ComplexRelativePaths/Library/testConly.h diff --git a/Source/cmExecProgramCommand.cxx b/Source/cmExecProgramCommand.cxx index 7e1ad766b..685e2fc50 100644 --- a/Source/cmExecProgramCommand.cxx +++ b/Source/cmExecProgramCommand.cxx @@ -28,7 +28,7 @@ bool cmExecProgramCommand::InitialPass(std::vector const& args) std::string arguments; bool doingargs = false; int count = 0; - for(int i=0; i < args.size(); ++i) + for(size_t i=0; i < args.size(); ++i) { if(doingargs) { diff --git a/Source/cmUnixMakefileGenerator.cxx b/Source/cmUnixMakefileGenerator.cxx index 789789b88..87847be35 100644 --- a/Source/cmUnixMakefileGenerator.cxx +++ b/Source/cmUnixMakefileGenerator.cxx @@ -427,14 +427,33 @@ void cmUnixMakefileGenerator::OutputLinkLibraries(std::ostream& fout, std::string runtimeSep; std::vector runtimeDirs; - if(m_Makefile->GetDefinition("CMAKE_SHLIB_RUNTIME_FLAG")) + bool cxx = tgt.HasCxx(); + if(!cxx) { - runtimeFlag = m_Makefile->GetDefinition("CMAKE_SHLIB_RUNTIME_FLAG"); + if(m_Makefile->GetDefinition("CMAKE_SHLIB_RUNTIME_FLAG")) + { + runtimeFlag = m_Makefile->GetDefinition("CMAKE_SHLIB_RUNTIME_FLAG"); + } + + if(m_Makefile->GetDefinition("CMAKE_SHLIB_RUNTIME_SEP")) + { + runtimeSep = m_Makefile->GetDefinition("CMAKE_SHLIB_RUNTIME_SEP"); + } } - if(m_Makefile->GetDefinition("CMAKE_SHLIB_RUNTIME_SEP")) + else { - runtimeSep = m_Makefile->GetDefinition("CMAKE_SHLIB_RUNTIME_SEP"); + if(m_Makefile->GetDefinition("CMAKE_CXX_SHLIB_RUNTIME_FLAG")) + { + runtimeFlag = m_Makefile->GetDefinition("CMAKE_CXX_SHLIB_RUNTIME_FLAG"); + } + + if(m_Makefile->GetDefinition("CMAKE_CXX_SHLIB_RUNTIME_SEP")) + { + runtimeSep = m_Makefile->GetDefinition("CMAKE_CXX_SHLIB_RUNTIME_SEP"); + } } + + // concatenate all paths or no? bool runtimeConcatenate = ( runtimeSep!="" ); @@ -607,13 +626,13 @@ void cmUnixMakefileGenerator::OutputSharedLibraryRule(std::ostream& fout, std::string command2; if(t.HasCxx()) { - command2 = "$(CMAKE_CXX_COMPILER) $(CMAKE_SHLIB_LINK_FLAGS) " - "$(CMAKE_SHLIB_BUILD_FLAGS) $(CMAKE_CXX_FLAGS) -o \\\n"; + command2 = "$(CMAKE_CXX_LINK_SHARED) $(CMAKE_CXX_SHLIB_LINK_FLAGS) " + "$(CMAKE_CXX_SHLIB_BUILD_FLAGS) $(CMAKE_CXX_FLAGS) -o \\\n"; } else { - command2 = "$(CMAKE_C_COMPILER) $(CMAKE_SHLIB_LINK_FLAGS) " - "$(CMAKE_SHLIB_BUILD_FLAGS) $(CMAKE_C_FLAGS) -o \\\n"; + command2 = "$(CMAKE_C_LINK_SHARED) $(CMAKE_SHLIB_LINK_FLAGS) " + "$(CMAKE_SHLIB_BUILD_FLAGS) -o \\\n"; } command2 += "\t "; std::string libName = m_LibraryOutputPath + "lib" + std::string(name) + "$(SHLIB_SUFFIX)"; @@ -651,13 +670,13 @@ void cmUnixMakefileGenerator::OutputModuleLibraryRule(std::ostream& fout, std::string command2; if(t.HasCxx()) { - command2 = "$(CMAKE_CXX_COMPILER) $(CMAKE_SHLIB_LINK_FLAGS) " - "$(CMAKE_SHLIB_BUILD_FLAGS) $(CMAKE_CXX_FLAGS) -o \\\n"; + command2 = "$(CMAKE_CXX_LINK_SHARED) $(CMAKE_CXX_SHLIB_LINK_FLAGS) " + "$(CMAKE_CXX_SHLIB_BUILD_FLAGS) $(CMAKE_CXX_FLAGS) -o \\\n"; } else { - command2 = "$(CMAKE_C_COMPILER) $(CMAKE_SHLIB_LINK_FLAGS) " - "$(CMAKE_SHLIB_BUILD_FLAGS) $(CMAKE_C_FLAGS) -o \\\n"; + command2 = "$(CMAKE_C_LINK_SHARED) $(CMAKE_SHLIB_LINK_FLAGS) " + "$(CMAKE_SHLIB_BUILD_FLAGS) -o \\\n"; } command2 += "\t "; std::string libName = m_LibraryOutputPath + "lib" + std::string(name) + "$(MODULE_SUFFIX)"; @@ -735,7 +754,7 @@ void cmUnixMakefileGenerator::OutputExecutableRule(std::ostream& fout, if(t.HasCxx()) { command = - "$(CMAKE_CXX_COMPILER) $(CMAKE_SHLIB_LINK_FLAGS) $(CMAKE_CXX_FLAGS) "; + "$(CMAKE_CXX_COMPILER) $(CMAKE_CXX_SHLIB_LINK_FLAGS) $(CMAKE_CXX_FLAGS) "; } else { @@ -1510,8 +1529,19 @@ void cmUnixMakefileGenerator::OutputMakeVariables(std::ostream& fout) "CMAKE_CXX_AR = @CMAKE_CXX_AR@\n" "CMAKE_CXX_AR_ARGS = @CMAKE_CXX_AR_ARGS@\n" "CMAKE_C_COMPILER = @CMAKE_C_COMPILER@\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" diff --git a/Templates/CCMakeSystemConfig.cmake.in b/Templates/CCMakeSystemConfig.cmake.in index af43238fc..dd65d0e9c 100644 --- a/Templates/CCMakeSystemConfig.cmake.in +++ b/Templates/CCMakeSystemConfig.cmake.in @@ -77,6 +77,8 @@ SET (CMAKE_SHLIB_RUNTIME_SEP "@CMAKE_SHLIB_RUNTIME_SEP@" CACHE STRING SET (CMAKE_SKIP_RPATH "NO" CACHE BOOL "If set, runtime paths are not added when using shared libraries.") +SET(CMAKE_C_LINK_SHARED "@CMAKE_C_LINK_SHARED@" CACHE STRING + "program used to link c shared libraries") # support for X11 SET (CMAKE_X_LIBS "@X_PRE_LIBS@ @X_LIBS@ -lX11 -lXext @X_EXTRA_LIBS@" CACHE STRING diff --git a/Templates/CXXCMakeSystemConfig.cmake.in b/Templates/CXXCMakeSystemConfig.cmake.in index 5b867fb94..454212029 100644 --- a/Templates/CXXCMakeSystemConfig.cmake.in +++ b/Templates/CXXCMakeSystemConfig.cmake.in @@ -2,6 +2,63 @@ # CMakeLocal.make.in should be in the directory where you run configure # in, which need not be the source directory # +SET(CMAKE_CXX_SHLIB_CFLAGS_TMP "@CMAKE_CXX_SHLIB_CFLAGS@" ) +SET(CMAKE_CXX_SHLIB_BUILD_FLAGS_TMP "@CMAKE_CXX_SHLIB_BUILD_FLAGS@") +SET(CMAKE_CXX_SHLIB_LINK_FLAGS_TMP "@CMAKE_CXX_SHLIB_LINK_FLAGS@") +SET(CMAKE_CXX_MODULE_BUILD_FLAGS_TMP "@CMAKE_CXX_MODULE_BUILD_FLAGS@") +SET(CMAKE_CXX_MODULE_LINK_FLAGS_TMP "@CMAKE_CXX_MODULE_LINK_FLAGS@") +SET(CMAKE_CXX_SHLIB_RUNTIME_FLAG_TMP "@CMAKE_CXX_SHLIB_RUNTIME_FLAG@") +SET(CMAKE_CXX_SHLIB_RUNTIME_SEP_TMP "@CMAKE_CXX_SHLIB_RUNTIME_SEP@") + + +# if no CXX versions of these exist, then use the c versions +IF( CMAKE_CXX_SHLIB_CFLAGS_TMP ) + SET(CMAKE_CXX_SHLIB_CFLAGS "${CMAKE_CXX_SHLIB_CFLAGS_TMP}" CACHE STRING "") +ELSE( CMAKE_CXX_SHLIB_CFLAGS_TMP ) + SET(CMAKE_CXX_SHLIB_CFLAGS "${CMAKE_SHLIB_CFLAGS}" CACHE STRING "") +ENDIF( CMAKE_CXX_SHLIB_CFLAGS_TMP ) + +IF( CMAKE_CXX_SHLIB_BUILD_FLAGS_TMP ) + SET(CMAKE_CXX_SHLIB_BUILD_FLAGS "${CMAKE_CXX_SHLIB_BUILD_FLAGS_TMP} CACHE STRING "") +ELSE( CMAKE_CXX_SHLIB_BUILD_FLAGS_TMP ) + SET(CMAKE_CXX_SHLIB_BUILD_FLAGS "${CMAKE_SHLIB_BUILD_FLAGS}" CACHE STRING "") +ENDIF( CMAKE_CXX_SHLIB_BUILD_FLAGS_TMP ) + +IF( CMAKE_CXX_SHLIB_LINK_FLAGS_TMP ) + SET(CMAKE_CXX_SHLIB_LINK_FLAGS "${CMAKE_CXX_SHLIB_LINK_FLAGS_TMP}" CACHE STRING "") +ELSE( CMAKE_CXX_SHLIB_LINK_FLAGS_TMP ) + SET(CMAKE_CXX_SHLIB_LINK_FLAGS "${CMAKE_SHLIB_LINK_FLAGS}" CACHE STRING "") +ENDIF( CMAKE_CXX_SHLIB_LINK_FLAGS_TMP ) + +IF( CMAKE_CXX_MODULE_BUILD_FLAGS_TMP ) + SET(CMAKE_CXX_MODULE_BUILD_FLAGS "${CMAKE_CXX_MODULE_BUILD_FLAGS_TMP}" CACHE STRING "" ) +ELSE( CMAKE_CXX_MODULE_BUILD_FLAGS_TMP ) + SET(CMAKE_CXX_MODULE_BUILD_FLAGS "${CMAKE_MODULE_BUILD_FLAGS}" CACHE STRING "" ) +ENDIF( CMAKE_CXX_MODULE_BUILD_FLAGS_TMP ) + +IF( CMAKE_CXX_MODULE_LINK_FLAGS_TMP ) + SET(CMAKE_CXX_MODULE_LINK_FLAGS "${CMAKE_CXX_MODULE_LINK_FLAGS_TMP}" CACHE STRING "") +ELSE( CMAKE_CXX_MODULE_LINK_FLAGS_TMP ) + SET(CMAKE_CXX_MODULE_LINK_FLAGS "${CMAKE_MODULE_LINK_FLAGS}" CACHE STRING "") +ENDIF( CMAKE_CXX_MODULE_LINK_FLAGS_TMP ) + +IF( CMAKE_CXX_SHLIB_RUNTIME_FLAG_TMP ) + SET(CMAKE_CXX_SHLIB_RUNTIME_FLAG "${CMAKE_CXX_SHLIB_RUNTIME_FLAG_TMP}" CACHE STRING "") +ELSE( CMAKE_CXX_SHLIB_RUNTIME_FLAG_TMP ) + SET(CMAKE_CXX_SHLIB_RUNTIME_FLAG "${CMAKE_SHLIB_RUNTIME_FLAG}" CACHE STRING "") +ENDIF( CMAKE_CXX_SHLIB_RUNTIME_FLAG_TMP ) + +IF( CMAKE_CXX_SHLIB_RUNTIME_SEP_TMP ) + SET(CMAKE_CXX_SHLIB_RUNTIME_SEP "${CMAKE_CXX_SHLIB_RUNTIME_SEP_TMP}" CACHE STRING "") +ELSE( CMAKE_CXX_SHLIB_RUNTIME_SEP_TMP ) + SET(CMAKE_CXX_SHLIB_RUNTIME_SEP "${CMAKE_SHLIB_RUNTIME_SEP}" CACHE STRING "") +ENDIF( CMAKE_CXX_SHLIB_RUNTIME_SEP_TMP ) + +SET(CMAKE_CXX_LINK_SHARED "@CMAKE_CXX_LINK_SHARED@" CACHE STRING + "program used to link c++ shared libraries") + + + SET (CMAKE_CXX_AR "@CMAKE_CXX_AR@" CACHE FILEPATH "Archive program used to make archive libraries of c++ object files.") diff --git a/Templates/cconfigure b/Templates/cconfigure index 76cd1b774..10a057a81 100755 --- a/Templates/cconfigure +++ b/Templates/cconfigure @@ -2381,6 +2381,7 @@ fi # Step 4: set configuration options based on system name and version. +CMAKE_C_LINK_SHARED=${CC} fullSrcDir=`cd $srcdir; pwd` case $system in @@ -2393,7 +2394,7 @@ case $system in CMAKE_MODULE_SUFFIX="..o" CMAKE_DL_LIBS="" echo $ac_n "checking for printf in -lld""... $ac_c" 1>&6 -echo "configure:2397: checking for printf in -lld" >&5 +echo "configure:2398: checking for printf in -lld" >&5 ac_lib_var=`echo ld'_'printf | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2401,7 +2402,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lld $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2417: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -2459,18 +2460,20 @@ fi CMAKE_SHLIB_RUNTIME_SEP=":" ;; HP-UX-*) + CMAKE_C_LINK_SHARED=ld CMAKE_SHLIB_CFLAGS="+Z" CMAKE_SHLIB_LD_LIBS="" CMAKE_SHLIB_SUFFIX=".sl" CMAKE_MODULE_SUFFIX=".sl" CMAKE_DL_LIBS="-ldld" - CMAKE_SHLIB_BUILD_FLAGS='+Z -Wl,-E -b -L/usr/lib' - CMAKE_SHLIB_LINK_FLAGS='-Wl,+s' - CMAKE_MODULE_BUILD_FLAGS='+Z -Wl,-E -b -L/usr/lib' - CMAKE_MODULE_LINK_FLAGS='-Wl,+s' - CMAKE_SHLIB_RUNTIME_FLAG='-Wl,+b,' + CMAKE_SHLIB_BUILD_FLAGS='+Z -E -b -L/usr/lib' + CMAKE_SHLIB_LINK_FLAGS='+s' + CMAKE_MODULE_BUILD_FLAGS='+Z -E -b -L/usr/lib' + CMAKE_MODULE_LINK_FLAGS='+s' + CMAKE_SHLIB_RUNTIME_FLAG='+b,' CMAKE_SHLIB_RUNTIME_SEP=':' if test $ac_cv_prog_gcc = yes; then + CMAKE_C_LINK_SHARED=${CC} CMAKE_SHLIB_CFLAGS="-fPIC" CMAKE_SHLIB_BUILD_FLAGS='-shared -Wl,-E -Wl,-b' CMAKE_SHLIB_LINK_FLAGS='-Wl,+s' @@ -2518,17 +2521,17 @@ fi else ac_safe=`echo "dld.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for dld.h""... $ac_c" 1>&6 -echo "configure:2522: checking for dld.h" >&5 +echo "configure:2525: checking for dld.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2532: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2535: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2837,17 +2840,17 @@ for ac_hdr in sys/prctl.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:2841: checking for $ac_hdr" >&5 +echo "configure:2844: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2851: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2854: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2892,17 +2895,17 @@ for ac_hdr in pthread.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:2896: checking for $ac_hdr" >&5 +echo "configure:2899: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2906: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2909: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2931,7 +2934,7 @@ done if test "$use_pthreads" = "yes"; then if test "$use_sproc" = "no"; then echo $ac_n "checking for pthread_create in -lpthreads""... $ac_c" 1>&6 -echo "configure:2935: checking for pthread_create in -lpthreads" >&5 +echo "configure:2938: checking for pthread_create in -lpthreads" >&5 ac_lib_var=`echo pthreads'_'pthread_create | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2939,7 +2942,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lpthreads $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2957: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -2971,7 +2974,7 @@ else fi echo $ac_n "checking for pthread_create in -lpthread""... $ac_c" 1>&6 -echo "configure:2975: checking for pthread_create in -lpthread" >&5 +echo "configure:2978: checking for pthread_create in -lpthread" >&5 ac_lib_var=`echo pthread'_'pthread_create | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2979,7 +2982,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lpthread $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2997: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -3013,7 +3016,7 @@ fi # Work around Solaris 5.6 and 5.7 bug: if test "`uname -s -r`" = "SunOS 5.6"; then echo $ac_n "checking for thr_create in -lthread""... $ac_c" 1>&6 -echo "configure:3017: checking for thr_create in -lthread" >&5 +echo "configure:3020: checking for thr_create in -lthread" >&5 ac_lib_var=`echo thread'_'thr_create | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -3021,7 +3024,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lthread $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3039: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -3055,7 +3058,7 @@ fi fi if test "`uname -s -r`" = "SunOS 5.7"; then echo $ac_n "checking for thr_create in -lthread""... $ac_c" 1>&6 -echo "configure:3059: checking for thr_create in -lthread" >&5 +echo "configure:3062: checking for thr_create in -lthread" >&5 ac_lib_var=`echo thread'_'thr_create | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -3063,7 +3066,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lthread $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3081: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -3168,7 +3171,7 @@ do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3172: checking for $ac_word" >&5 +echo "configure:3175: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_CMAKE_AR_TMP'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3381,6 +3384,7 @@ s%@CMAKE_WORDS_BIGENDIAN@%$CMAKE_WORDS_BIGENDIAN%g s%@CMAKE_HAVE_LIMITS_H@%$CMAKE_HAVE_LIMITS_H%g s%@CMAKE_HAVE_UNISTD_H@%$CMAKE_HAVE_UNISTD_H%g s%@fullSrcDir@%$fullSrcDir%g +s%@CMAKE_C_LINK_SHARED@%$CMAKE_C_LINK_SHARED%g s%@CMAKE_SHLIB_LINK_FLAGS@%$CMAKE_SHLIB_LINK_FLAGS%g s%@CMAKE_SHLIB_BUILD_FLAGS@%$CMAKE_SHLIB_BUILD_FLAGS%g s%@CMAKE_MODULE_LINK_FLAGS@%$CMAKE_MODULE_LINK_FLAGS%g diff --git a/Templates/cconfigure.in b/Templates/cconfigure.in index 4fe7c445e..49e34d2c2 100644 --- a/Templates/cconfigure.in +++ b/Templates/cconfigure.in @@ -142,6 +142,7 @@ AC_CHECK_LIB(dl, dlopen, have_dl=yes, have_dl=no) # Step 4: set configuration options based on system name and version. +CMAKE_C_LINK_SHARED=${CC} fullSrcDir=`cd $srcdir; pwd` AC_SUBST(fullSrcDir) case $system in @@ -181,18 +182,20 @@ case $system in CMAKE_SHLIB_RUNTIME_SEP=":" ;; HP-UX-*) + CMAKE_C_LINK_SHARED=ld CMAKE_SHLIB_CFLAGS="+Z" CMAKE_SHLIB_LD_LIBS="" CMAKE_SHLIB_SUFFIX=".sl" CMAKE_MODULE_SUFFIX=".sl" CMAKE_DL_LIBS="-ldld" - CMAKE_SHLIB_BUILD_FLAGS='+Z -Wl,-E -b -L/usr/lib' - CMAKE_SHLIB_LINK_FLAGS='-Wl,+s' - CMAKE_MODULE_BUILD_FLAGS='+Z -Wl,-E -b -L/usr/lib' - CMAKE_MODULE_LINK_FLAGS='-Wl,+s' - CMAKE_SHLIB_RUNTIME_FLAG='-Wl,+b,' + CMAKE_SHLIB_BUILD_FLAGS='+Z -E -b -L/usr/lib' + CMAKE_SHLIB_LINK_FLAGS='+s' + CMAKE_MODULE_BUILD_FLAGS='+Z -E -b -L/usr/lib' + CMAKE_MODULE_LINK_FLAGS='+s' + CMAKE_SHLIB_RUNTIME_FLAG='+b,' CMAKE_SHLIB_RUNTIME_SEP=':' if test $ac_cv_prog_gcc = yes; then + CMAKE_C_LINK_SHARED=${CC} CMAKE_SHLIB_CFLAGS="-fPIC" CMAKE_SHLIB_BUILD_FLAGS='-shared -Wl,-E -Wl,-b' CMAKE_SHLIB_LINK_FLAGS='-Wl,+s' @@ -479,7 +482,7 @@ if test "${SHLIB_CFLAGS}" != ""; then fi CMAKE_LD_SEARCH_FLAGS="${LD_SEARCH_FLAGS}" - +AC_SUBST(CMAKE_C_LINK_SHARED) AC_SUBST(CMAKE_SHLIB_LINK_FLAGS) AC_SUBST(CMAKE_SHLIB_BUILD_FLAGS) AC_SUBST(CMAKE_MODULE_LINK_FLAGS) diff --git a/Templates/cxxconfigure b/Templates/cxxconfigure index 06e707dda..dd366fb09 100755 --- a/Templates/cxxconfigure +++ b/Templates/cxxconfigure @@ -887,6 +887,31 @@ if test $ac_cv_prog_gxx = yes; then fi +CMAKE_CXX_LINK_SHARED=${CXX} +case $system in + HP-UX-*) + CMAKE_CXX_SHLIB_CFLAGS="+Z" + CMAKE_CXX_SHLIB_SUFFIX=".sl" + CMAKE_CXX_MODULE_SUFFIX=".sl" + CMAKE_CXX_SHLIB_BUILD_FLAGS='+Z -Wl,-E -b -L/usr/lib' + CMAKE_CXX_SHLIB_LINK_FLAGS='-Wl,+s' + CMAKE_CXX_MODULE_BUILD_FLAGS='+Z -Wl,-E -b -L/usr/lib' + CMAKE_CXX_MODULE_LINK_FLAGS='-Wl,+s' + CMAKE_CXX_SHLIB_RUNTIME_FLAG='-Wl,+b,' + CMAKE_CXX_SHLIB_RUNTIME_SEP=':' +esac +# CXX versions of shared flags + + + + + + + + + + + # generate output files. # create mkdir files just to make some of the directories @@ -1044,6 +1069,14 @@ s%@CMAKE_NO_ANSI_FOR_SCOPE@%$CMAKE_NO_ANSI_FOR_SCOPE%g s%@CMAKE_AR_TMP@%$CMAKE_AR_TMP%g s%@CMAKE_CXX_AR@%$CMAKE_CXX_AR%g s%@CMAKE_CXX_AR_ARGS@%$CMAKE_CXX_AR_ARGS%g +s%@CMAKE_CXX_LINK_SHARED@%$CMAKE_CXX_LINK_SHARED%g +s%@CMAKE_CXX_SHLIB_CFLAGS@%$CMAKE_CXX_SHLIB_CFLAGS%g +s%@CMAKE_CXX_SHLIB_BUILD_FLAGS@%$CMAKE_CXX_SHLIB_BUILD_FLAGS%g +s%@CMAKE_CXX_SHLIB_LINK_FLAGS@%$CMAKE_CXX_SHLIB_LINK_FLAGS%g +s%@CMAKE_CXX_MODULE_BUILD_FLAGS@%$CMAKE_CXX_MODULE_BUILD_FLAGS%g +s%@CMAKE_CXX_MODULE_LINK_FLAGS@%$CMAKE_CXX_MODULE_LINK_FLAGS%g +s%@CMAKE_CXX_SHLIB_RUNTIME_FLAG@%$CMAKE_CXX_SHLIB_RUNTIME_FLAG%g +s%@CMAKE_CXX_SHLIB_RUNTIME_SEP@%$CMAKE_CXX_SHLIB_RUNTIME_SEP%g s%@CMAKE_COMPILER_IS_GNUCXX@%$CMAKE_COMPILER_IS_GNUCXX%g CEOF diff --git a/Templates/cxxconfigure.in b/Templates/cxxconfigure.in index b591237ad..b45146890 100644 --- a/Templates/cxxconfigure.in +++ b/Templates/cxxconfigure.in @@ -180,6 +180,31 @@ if test $ac_cv_prog_gxx = yes; then CMAKE_COMPILER_IS_GNUCXX=1 fi + +CMAKE_CXX_LINK_SHARED=${CXX} +case $system in + HP-UX-*) + CMAKE_CXX_SHLIB_CFLAGS="+Z" + CMAKE_CXX_SHLIB_SUFFIX=".sl" + CMAKE_CXX_MODULE_SUFFIX=".sl" + CMAKE_CXX_SHLIB_BUILD_FLAGS='+Z -Wl,-E -b -L/usr/lib' + CMAKE_CXX_SHLIB_LINK_FLAGS='-Wl,+s' + CMAKE_CXX_MODULE_BUILD_FLAGS='+Z -Wl,-E -b -L/usr/lib' + CMAKE_CXX_MODULE_LINK_FLAGS='-Wl,+s' + CMAKE_CXX_SHLIB_RUNTIME_FLAG='-Wl,+b,' + CMAKE_CXX_SHLIB_RUNTIME_SEP=':' +esac +# CXX versions of shared flags +AC_SUBST(CMAKE_CXX_LINK_SHARED) +AC_SUBST(CMAKE_CXX_SHLIB_CFLAGS) +AC_SUBST(CMAKE_CXX_SHLIB_BUILD_FLAGS) +AC_SUBST(CMAKE_CXX_SHLIB_LINK_FLAGS) +AC_SUBST(CMAKE_CXX_MODULE_BUILD_FLAGS) +AC_SUBST(CMAKE_CXX_MODULE_LINK_FLAGS) +AC_SUBST(CMAKE_CXX_SHLIB_RUNTIME_FLAG) +AC_SUBST(CMAKE_CXX_SHLIB_RUNTIME_SEP) + + AC_SUBST(CMAKE_COMPILER_IS_GNUCXX) # generate output files. # create mkdir files just to make some of the directories diff --git a/Tests/Complex/Executable/CMakeLists.txt b/Tests/Complex/Executable/CMakeLists.txt index a3ad8fd5e..7468926b6 100644 --- a/Tests/Complex/Executable/CMakeLists.txt +++ b/Tests/Complex/Executable/CMakeLists.txt @@ -4,7 +4,7 @@ SET_SOURCE_FILES_PROPERTIES(complex COMPILE_FLAGS "-DFILE_HAS_EXTRA_COMPILE_FLAGS") ADD_EXECUTABLE(complex complex) -SET(COMPLEX_LIBS CMakeTestLibrary;CMakeTestLibraryShared) +SET(COMPLEX_LIBS CMakeTestLibrary;CMakeTestLibraryShared;CMakeTestCLibraryShared) TARGET_LINK_LIBRARIES(complex ${COMPLEX_LIBS}) # diff --git a/Tests/Complex/Executable/complex.cxx b/Tests/Complex/Executable/complex.cxx index 61ffd8f83..6607d7de7 100644 --- a/Tests/Complex/Executable/complex.cxx +++ b/Tests/Complex/Executable/complex.cxx @@ -2,6 +2,9 @@ #include "ExtraSources/file1.h" #include "file2.h" #include "sharedFile.h" +extern "C" { +#include "testConly.h" +} #include "cmStandardIncludes.h" #include "cmSystemTools.h" @@ -103,6 +106,14 @@ int main() { cmPassed("Call to sharedFunction from shared library worked."); } + if(CsharedFunction() != 1) + { + cmFailed("Call to C sharedFunction from shared library failed."); + } + else + { + cmPassed("Call to C sharedFunction from shared library worked."); + } if(file1() != 1) { diff --git a/Tests/Complex/Library/CMakeLists.txt b/Tests/Complex/Library/CMakeLists.txt index c01f50124..19cb6cd3f 100644 --- a/Tests/Complex/Library/CMakeLists.txt +++ b/Tests/Complex/Library/CMakeLists.txt @@ -26,6 +26,8 @@ ADD_LIBRARY(CMakeTestLibrary LibrarySources) SOURCE_FILES(SharedLibrarySources sharedFile) ADD_LIBRARY(CMakeTestLibraryShared SHARED SharedLibrarySources) +ADD_LIBRARY(CMakeTestCLibraryShared SHARED testConly.c) + # # Attach a post-build custom-command to the lib. # It runs ${CREATE_FILE_EXE} which will create a file. diff --git a/Tests/Complex/Library/testConly.c b/Tests/Complex/Library/testConly.c new file mode 100644 index 000000000..d2d5294b1 --- /dev/null +++ b/Tests/Complex/Library/testConly.c @@ -0,0 +1,6 @@ +#include "sharedFile.h" + +int CsharedFunction() +{ + return 1; +} diff --git a/Tests/Complex/Library/testConly.h b/Tests/Complex/Library/testConly.h new file mode 100644 index 000000000..8553a6b59 --- /dev/null +++ b/Tests/Complex/Library/testConly.h @@ -0,0 +1,12 @@ +#if defined(_WIN32) || defined(WIN32) /* Win32 version */ +#ifdef CMakeTestLibraryShared_EXPORTS +# define CMakeTest_EXPORT __declspec(dllexport) +#else +# define CMakeTest_EXPORT __declspec(dllimport) +#endif +#else +// unix needs nothing +#define CMakeTest_EXPORT +#endif + +CMakeTest_EXPORT int CsharedFunction(); diff --git a/Tests/ComplexOneConfig/Executable/CMakeLists.txt b/Tests/ComplexOneConfig/Executable/CMakeLists.txt index a3ad8fd5e..7468926b6 100644 --- a/Tests/ComplexOneConfig/Executable/CMakeLists.txt +++ b/Tests/ComplexOneConfig/Executable/CMakeLists.txt @@ -4,7 +4,7 @@ SET_SOURCE_FILES_PROPERTIES(complex COMPILE_FLAGS "-DFILE_HAS_EXTRA_COMPILE_FLAGS") ADD_EXECUTABLE(complex complex) -SET(COMPLEX_LIBS CMakeTestLibrary;CMakeTestLibraryShared) +SET(COMPLEX_LIBS CMakeTestLibrary;CMakeTestLibraryShared;CMakeTestCLibraryShared) TARGET_LINK_LIBRARIES(complex ${COMPLEX_LIBS}) # diff --git a/Tests/ComplexOneConfig/Executable/complex.cxx b/Tests/ComplexOneConfig/Executable/complex.cxx index 61ffd8f83..6607d7de7 100644 --- a/Tests/ComplexOneConfig/Executable/complex.cxx +++ b/Tests/ComplexOneConfig/Executable/complex.cxx @@ -2,6 +2,9 @@ #include "ExtraSources/file1.h" #include "file2.h" #include "sharedFile.h" +extern "C" { +#include "testConly.h" +} #include "cmStandardIncludes.h" #include "cmSystemTools.h" @@ -103,6 +106,14 @@ int main() { cmPassed("Call to sharedFunction from shared library worked."); } + if(CsharedFunction() != 1) + { + cmFailed("Call to C sharedFunction from shared library failed."); + } + else + { + cmPassed("Call to C sharedFunction from shared library worked."); + } if(file1() != 1) { diff --git a/Tests/ComplexOneConfig/Library/CMakeLists.txt b/Tests/ComplexOneConfig/Library/CMakeLists.txt index c01f50124..19cb6cd3f 100644 --- a/Tests/ComplexOneConfig/Library/CMakeLists.txt +++ b/Tests/ComplexOneConfig/Library/CMakeLists.txt @@ -26,6 +26,8 @@ ADD_LIBRARY(CMakeTestLibrary LibrarySources) SOURCE_FILES(SharedLibrarySources sharedFile) ADD_LIBRARY(CMakeTestLibraryShared SHARED SharedLibrarySources) +ADD_LIBRARY(CMakeTestCLibraryShared SHARED testConly.c) + # # Attach a post-build custom-command to the lib. # It runs ${CREATE_FILE_EXE} which will create a file. diff --git a/Tests/ComplexOneConfig/Library/testConly.c b/Tests/ComplexOneConfig/Library/testConly.c new file mode 100644 index 000000000..d2d5294b1 --- /dev/null +++ b/Tests/ComplexOneConfig/Library/testConly.c @@ -0,0 +1,6 @@ +#include "sharedFile.h" + +int CsharedFunction() +{ + return 1; +} diff --git a/Tests/ComplexOneConfig/Library/testConly.h b/Tests/ComplexOneConfig/Library/testConly.h new file mode 100644 index 000000000..8553a6b59 --- /dev/null +++ b/Tests/ComplexOneConfig/Library/testConly.h @@ -0,0 +1,12 @@ +#if defined(_WIN32) || defined(WIN32) /* Win32 version */ +#ifdef CMakeTestLibraryShared_EXPORTS +# define CMakeTest_EXPORT __declspec(dllexport) +#else +# define CMakeTest_EXPORT __declspec(dllimport) +#endif +#else +// unix needs nothing +#define CMakeTest_EXPORT +#endif + +CMakeTest_EXPORT int CsharedFunction(); diff --git a/Tests/ComplexRelativePaths/Executable/CMakeLists.txt b/Tests/ComplexRelativePaths/Executable/CMakeLists.txt index a3ad8fd5e..7468926b6 100644 --- a/Tests/ComplexRelativePaths/Executable/CMakeLists.txt +++ b/Tests/ComplexRelativePaths/Executable/CMakeLists.txt @@ -4,7 +4,7 @@ SET_SOURCE_FILES_PROPERTIES(complex COMPILE_FLAGS "-DFILE_HAS_EXTRA_COMPILE_FLAGS") ADD_EXECUTABLE(complex complex) -SET(COMPLEX_LIBS CMakeTestLibrary;CMakeTestLibraryShared) +SET(COMPLEX_LIBS CMakeTestLibrary;CMakeTestLibraryShared;CMakeTestCLibraryShared) TARGET_LINK_LIBRARIES(complex ${COMPLEX_LIBS}) # diff --git a/Tests/ComplexRelativePaths/Executable/complex.cxx b/Tests/ComplexRelativePaths/Executable/complex.cxx index 61ffd8f83..6607d7de7 100644 --- a/Tests/ComplexRelativePaths/Executable/complex.cxx +++ b/Tests/ComplexRelativePaths/Executable/complex.cxx @@ -2,6 +2,9 @@ #include "ExtraSources/file1.h" #include "file2.h" #include "sharedFile.h" +extern "C" { +#include "testConly.h" +} #include "cmStandardIncludes.h" #include "cmSystemTools.h" @@ -103,6 +106,14 @@ int main() { cmPassed("Call to sharedFunction from shared library worked."); } + if(CsharedFunction() != 1) + { + cmFailed("Call to C sharedFunction from shared library failed."); + } + else + { + cmPassed("Call to C sharedFunction from shared library worked."); + } if(file1() != 1) { diff --git a/Tests/ComplexRelativePaths/Library/CMakeLists.txt b/Tests/ComplexRelativePaths/Library/CMakeLists.txt index c01f50124..19cb6cd3f 100644 --- a/Tests/ComplexRelativePaths/Library/CMakeLists.txt +++ b/Tests/ComplexRelativePaths/Library/CMakeLists.txt @@ -26,6 +26,8 @@ ADD_LIBRARY(CMakeTestLibrary LibrarySources) SOURCE_FILES(SharedLibrarySources sharedFile) ADD_LIBRARY(CMakeTestLibraryShared SHARED SharedLibrarySources) +ADD_LIBRARY(CMakeTestCLibraryShared SHARED testConly.c) + # # Attach a post-build custom-command to the lib. # It runs ${CREATE_FILE_EXE} which will create a file. diff --git a/Tests/ComplexRelativePaths/Library/testConly.c b/Tests/ComplexRelativePaths/Library/testConly.c new file mode 100644 index 000000000..d2d5294b1 --- /dev/null +++ b/Tests/ComplexRelativePaths/Library/testConly.c @@ -0,0 +1,6 @@ +#include "sharedFile.h" + +int CsharedFunction() +{ + return 1; +} diff --git a/Tests/ComplexRelativePaths/Library/testConly.h b/Tests/ComplexRelativePaths/Library/testConly.h new file mode 100644 index 000000000..8553a6b59 --- /dev/null +++ b/Tests/ComplexRelativePaths/Library/testConly.h @@ -0,0 +1,12 @@ +#if defined(_WIN32) || defined(WIN32) /* Win32 version */ +#ifdef CMakeTestLibraryShared_EXPORTS +# define CMakeTest_EXPORT __declspec(dllexport) +#else +# define CMakeTest_EXPORT __declspec(dllimport) +#endif +#else +// unix needs nothing +#define CMakeTest_EXPORT +#endif + +CMakeTest_EXPORT int CsharedFunction();