ENH: use separate vars for creating c++ and c shared libraries and add a test for c libraries

This commit is contained in:
Bill Hoffman 2002-04-08 13:36:18 -04:00
parent 7883b6c7dc
commit 65e3edea04
23 changed files with 301 additions and 54 deletions

View File

@ -28,7 +28,7 @@ bool cmExecProgramCommand::InitialPass(std::vector<std::string> const& args)
std::string arguments; std::string arguments;
bool doingargs = false; bool doingargs = false;
int count = 0; int count = 0;
for(int i=0; i < args.size(); ++i) for(size_t i=0; i < args.size(); ++i)
{ {
if(doingargs) if(doingargs)
{ {

View File

@ -427,14 +427,33 @@ void cmUnixMakefileGenerator::OutputLinkLibraries(std::ostream& fout,
std::string runtimeSep; std::string runtimeSep;
std::vector<std::string> runtimeDirs; std::vector<std::string> runtimeDirs;
bool cxx = tgt.HasCxx();
if(!cxx)
{
if(m_Makefile->GetDefinition("CMAKE_SHLIB_RUNTIME_FLAG")) if(m_Makefile->GetDefinition("CMAKE_SHLIB_RUNTIME_FLAG"))
{ {
runtimeFlag = m_Makefile->GetDefinition("CMAKE_SHLIB_RUNTIME_FLAG"); runtimeFlag = m_Makefile->GetDefinition("CMAKE_SHLIB_RUNTIME_FLAG");
} }
if(m_Makefile->GetDefinition("CMAKE_SHLIB_RUNTIME_SEP")) if(m_Makefile->GetDefinition("CMAKE_SHLIB_RUNTIME_SEP"))
{ {
runtimeSep = m_Makefile->GetDefinition("CMAKE_SHLIB_RUNTIME_SEP"); runtimeSep = m_Makefile->GetDefinition("CMAKE_SHLIB_RUNTIME_SEP");
} }
}
else
{
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? // concatenate all paths or no?
bool runtimeConcatenate = ( runtimeSep!="" ); bool runtimeConcatenate = ( runtimeSep!="" );
@ -607,13 +626,13 @@ void cmUnixMakefileGenerator::OutputSharedLibraryRule(std::ostream& fout,
std::string command2; std::string command2;
if(t.HasCxx()) if(t.HasCxx())
{ {
command2 = "$(CMAKE_CXX_COMPILER) $(CMAKE_SHLIB_LINK_FLAGS) " command2 = "$(CMAKE_CXX_LINK_SHARED) $(CMAKE_CXX_SHLIB_LINK_FLAGS) "
"$(CMAKE_SHLIB_BUILD_FLAGS) $(CMAKE_CXX_FLAGS) -o \\\n"; "$(CMAKE_CXX_SHLIB_BUILD_FLAGS) $(CMAKE_CXX_FLAGS) -o \\\n";
} }
else else
{ {
command2 = "$(CMAKE_C_COMPILER) $(CMAKE_SHLIB_LINK_FLAGS) " command2 = "$(CMAKE_C_LINK_SHARED) $(CMAKE_SHLIB_LINK_FLAGS) "
"$(CMAKE_SHLIB_BUILD_FLAGS) $(CMAKE_C_FLAGS) -o \\\n"; "$(CMAKE_SHLIB_BUILD_FLAGS) -o \\\n";
} }
command2 += "\t "; command2 += "\t ";
std::string libName = m_LibraryOutputPath + "lib" + std::string(name) + "$(SHLIB_SUFFIX)"; std::string libName = m_LibraryOutputPath + "lib" + std::string(name) + "$(SHLIB_SUFFIX)";
@ -651,13 +670,13 @@ void cmUnixMakefileGenerator::OutputModuleLibraryRule(std::ostream& fout,
std::string command2; std::string command2;
if(t.HasCxx()) if(t.HasCxx())
{ {
command2 = "$(CMAKE_CXX_COMPILER) $(CMAKE_SHLIB_LINK_FLAGS) " command2 = "$(CMAKE_CXX_LINK_SHARED) $(CMAKE_CXX_SHLIB_LINK_FLAGS) "
"$(CMAKE_SHLIB_BUILD_FLAGS) $(CMAKE_CXX_FLAGS) -o \\\n"; "$(CMAKE_CXX_SHLIB_BUILD_FLAGS) $(CMAKE_CXX_FLAGS) -o \\\n";
} }
else else
{ {
command2 = "$(CMAKE_C_COMPILER) $(CMAKE_SHLIB_LINK_FLAGS) " command2 = "$(CMAKE_C_LINK_SHARED) $(CMAKE_SHLIB_LINK_FLAGS) "
"$(CMAKE_SHLIB_BUILD_FLAGS) $(CMAKE_C_FLAGS) -o \\\n"; "$(CMAKE_SHLIB_BUILD_FLAGS) -o \\\n";
} }
command2 += "\t "; command2 += "\t ";
std::string libName = m_LibraryOutputPath + "lib" + std::string(name) + "$(MODULE_SUFFIX)"; std::string libName = m_LibraryOutputPath + "lib" + std::string(name) + "$(MODULE_SUFFIX)";
@ -735,7 +754,7 @@ void cmUnixMakefileGenerator::OutputExecutableRule(std::ostream& fout,
if(t.HasCxx()) if(t.HasCxx())
{ {
command = command =
"$(CMAKE_CXX_COMPILER) $(CMAKE_SHLIB_LINK_FLAGS) $(CMAKE_CXX_FLAGS) "; "$(CMAKE_CXX_COMPILER) $(CMAKE_CXX_SHLIB_LINK_FLAGS) $(CMAKE_CXX_FLAGS) ";
} }
else else
{ {
@ -1510,8 +1529,19 @@ void cmUnixMakefileGenerator::OutputMakeVariables(std::ostream& fout)
"CMAKE_CXX_AR = @CMAKE_CXX_AR@\n" "CMAKE_CXX_AR = @CMAKE_CXX_AR@\n"
"CMAKE_CXX_AR_ARGS = @CMAKE_CXX_AR_ARGS@\n" "CMAKE_CXX_AR_ARGS = @CMAKE_CXX_AR_ARGS@\n"
"CMAKE_C_COMPILER = @CMAKE_C_COMPILER@\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_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" "\n"
"CMAKE_CXX_COMPILER = @CMAKE_CXX_COMPILER@\n" "CMAKE_CXX_COMPILER = @CMAKE_CXX_COMPILER@\n"
"CMAKE_CXX_FLAGS = @CMAKE_CXX_FLAGS@\n" "CMAKE_CXX_FLAGS = @CMAKE_CXX_FLAGS@\n"

View File

@ -77,6 +77,8 @@ SET (CMAKE_SHLIB_RUNTIME_SEP "@CMAKE_SHLIB_RUNTIME_SEP@" CACHE STRING
SET (CMAKE_SKIP_RPATH "NO" CACHE BOOL SET (CMAKE_SKIP_RPATH "NO" CACHE BOOL
"If set, runtime paths are not added when using shared libraries.") "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 # support for X11
SET (CMAKE_X_LIBS "@X_PRE_LIBS@ @X_LIBS@ -lX11 -lXext @X_EXTRA_LIBS@" CACHE STRING SET (CMAKE_X_LIBS "@X_PRE_LIBS@ @X_LIBS@ -lX11 -lXext @X_EXTRA_LIBS@" CACHE STRING

View File

@ -2,6 +2,63 @@
# CMakeLocal.make.in should be in the directory where you run configure # CMakeLocal.make.in should be in the directory where you run configure
# in, which need not be the source directory # 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 SET (CMAKE_CXX_AR "@CMAKE_CXX_AR@" CACHE FILEPATH
"Archive program used to make archive libraries of c++ object files.") "Archive program used to make archive libraries of c++ object files.")

View File

@ -2381,6 +2381,7 @@ fi
# Step 4: set configuration options based on system name and version. # Step 4: set configuration options based on system name and version.
CMAKE_C_LINK_SHARED=${CC}
fullSrcDir=`cd $srcdir; pwd` fullSrcDir=`cd $srcdir; pwd`
case $system in case $system in
@ -2393,7 +2394,7 @@ case $system in
CMAKE_MODULE_SUFFIX="..o" CMAKE_MODULE_SUFFIX="..o"
CMAKE_DL_LIBS="" CMAKE_DL_LIBS=""
echo $ac_n "checking for printf in -lld""... $ac_c" 1>&6 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_%'` ac_lib_var=`echo ld'_'printf | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
@ -2401,7 +2402,7 @@ else
ac_save_LIBS="$LIBS" ac_save_LIBS="$LIBS"
LIBS="-lld $LIBS" LIBS="-lld $LIBS"
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 2405 "configure" #line 2406 "configure"
#include "confdefs.h" #include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */ /* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2 /* We use char because int might match the return type of a gcc2
@ -2412,7 +2413,7 @@ int main() {
printf() printf()
; return 0; } ; return 0; }
EOF EOF
if { (eval echo configure:2416: \"$ac_link\") 1>&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* rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes" eval "ac_cv_lib_$ac_lib_var=yes"
else else
@ -2459,18 +2460,20 @@ fi
CMAKE_SHLIB_RUNTIME_SEP=":" CMAKE_SHLIB_RUNTIME_SEP=":"
;; ;;
HP-UX-*) HP-UX-*)
CMAKE_C_LINK_SHARED=ld
CMAKE_SHLIB_CFLAGS="+Z" CMAKE_SHLIB_CFLAGS="+Z"
CMAKE_SHLIB_LD_LIBS="" CMAKE_SHLIB_LD_LIBS=""
CMAKE_SHLIB_SUFFIX=".sl" CMAKE_SHLIB_SUFFIX=".sl"
CMAKE_MODULE_SUFFIX=".sl" CMAKE_MODULE_SUFFIX=".sl"
CMAKE_DL_LIBS="-ldld" CMAKE_DL_LIBS="-ldld"
CMAKE_SHLIB_BUILD_FLAGS='+Z -Wl,-E -b -L/usr/lib' CMAKE_SHLIB_BUILD_FLAGS='+Z -E -b -L/usr/lib'
CMAKE_SHLIB_LINK_FLAGS='-Wl,+s' CMAKE_SHLIB_LINK_FLAGS='+s'
CMAKE_MODULE_BUILD_FLAGS='+Z -Wl,-E -b -L/usr/lib' CMAKE_MODULE_BUILD_FLAGS='+Z -E -b -L/usr/lib'
CMAKE_MODULE_LINK_FLAGS='-Wl,+s' CMAKE_MODULE_LINK_FLAGS='+s'
CMAKE_SHLIB_RUNTIME_FLAG='-Wl,+b,' CMAKE_SHLIB_RUNTIME_FLAG='+b,'
CMAKE_SHLIB_RUNTIME_SEP=':' CMAKE_SHLIB_RUNTIME_SEP=':'
if test $ac_cv_prog_gcc = yes; then if test $ac_cv_prog_gcc = yes; then
CMAKE_C_LINK_SHARED=${CC}
CMAKE_SHLIB_CFLAGS="-fPIC" CMAKE_SHLIB_CFLAGS="-fPIC"
CMAKE_SHLIB_BUILD_FLAGS='-shared -Wl,-E -Wl,-b' CMAKE_SHLIB_BUILD_FLAGS='-shared -Wl,-E -Wl,-b'
CMAKE_SHLIB_LINK_FLAGS='-Wl,+s' CMAKE_SHLIB_LINK_FLAGS='-Wl,+s'
@ -2518,17 +2521,17 @@ fi
else else
ac_safe=`echo "dld.h" | sed 'y%./+-%__p_%'` ac_safe=`echo "dld.h" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for dld.h""... $ac_c" 1>&6 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 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 2527 "configure" #line 2530 "configure"
#include "confdefs.h" #include "confdefs.h"
#include <dld.h> #include <dld.h>
EOF EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" 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}\$"` ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then if test -z "$ac_err"; then
rm -rf conftest* rm -rf conftest*
@ -2837,17 +2840,17 @@ for ac_hdr in sys/prctl.h
do do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 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 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 2846 "configure" #line 2849 "configure"
#include "confdefs.h" #include "confdefs.h"
#include <$ac_hdr> #include <$ac_hdr>
EOF EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" 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}\$"` ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then if test -z "$ac_err"; then
rm -rf conftest* rm -rf conftest*
@ -2892,17 +2895,17 @@ for ac_hdr in pthread.h
do do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 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 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 2901 "configure" #line 2904 "configure"
#include "confdefs.h" #include "confdefs.h"
#include <$ac_hdr> #include <$ac_hdr>
EOF EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" 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}\$"` ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then if test -z "$ac_err"; then
rm -rf conftest* rm -rf conftest*
@ -2931,7 +2934,7 @@ done
if test "$use_pthreads" = "yes"; then if test "$use_pthreads" = "yes"; then
if test "$use_sproc" = "no"; then if test "$use_sproc" = "no"; then
echo $ac_n "checking for pthread_create in -lpthreads""... $ac_c" 1>&6 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_%'` ac_lib_var=`echo pthreads'_'pthread_create | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
@ -2939,7 +2942,7 @@ else
ac_save_LIBS="$LIBS" ac_save_LIBS="$LIBS"
LIBS="-lpthreads $LIBS" LIBS="-lpthreads $LIBS"
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 2943 "configure" #line 2946 "configure"
#include "confdefs.h" #include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */ /* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2 /* We use char because int might match the return type of a gcc2
@ -2950,7 +2953,7 @@ int main() {
pthread_create() pthread_create()
; return 0; } ; return 0; }
EOF EOF
if { (eval echo configure:2954: \"$ac_link\") 1>&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* rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes" eval "ac_cv_lib_$ac_lib_var=yes"
else else
@ -2971,7 +2974,7 @@ else
fi fi
echo $ac_n "checking for pthread_create in -lpthread""... $ac_c" 1>&6 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_%'` ac_lib_var=`echo pthread'_'pthread_create | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
@ -2979,7 +2982,7 @@ else
ac_save_LIBS="$LIBS" ac_save_LIBS="$LIBS"
LIBS="-lpthread $LIBS" LIBS="-lpthread $LIBS"
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 2983 "configure" #line 2986 "configure"
#include "confdefs.h" #include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */ /* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2 /* We use char because int might match the return type of a gcc2
@ -2990,7 +2993,7 @@ int main() {
pthread_create() pthread_create()
; return 0; } ; return 0; }
EOF EOF
if { (eval echo configure:2994: \"$ac_link\") 1>&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* rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes" eval "ac_cv_lib_$ac_lib_var=yes"
else else
@ -3013,7 +3016,7 @@ fi
# Work around Solaris 5.6 and 5.7 bug: # Work around Solaris 5.6 and 5.7 bug:
if test "`uname -s -r`" = "SunOS 5.6"; then if test "`uname -s -r`" = "SunOS 5.6"; then
echo $ac_n "checking for thr_create in -lthread""... $ac_c" 1>&6 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_%'` ac_lib_var=`echo thread'_'thr_create | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
@ -3021,7 +3024,7 @@ else
ac_save_LIBS="$LIBS" ac_save_LIBS="$LIBS"
LIBS="-lthread $LIBS" LIBS="-lthread $LIBS"
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 3025 "configure" #line 3028 "configure"
#include "confdefs.h" #include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */ /* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2 /* We use char because int might match the return type of a gcc2
@ -3032,7 +3035,7 @@ int main() {
thr_create() thr_create()
; return 0; } ; return 0; }
EOF EOF
if { (eval echo configure:3036: \"$ac_link\") 1>&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* rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes" eval "ac_cv_lib_$ac_lib_var=yes"
else else
@ -3055,7 +3058,7 @@ fi
fi fi
if test "`uname -s -r`" = "SunOS 5.7"; then if test "`uname -s -r`" = "SunOS 5.7"; then
echo $ac_n "checking for thr_create in -lthread""... $ac_c" 1>&6 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_%'` ac_lib_var=`echo thread'_'thr_create | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
@ -3063,7 +3066,7 @@ else
ac_save_LIBS="$LIBS" ac_save_LIBS="$LIBS"
LIBS="-lthread $LIBS" LIBS="-lthread $LIBS"
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 3067 "configure" #line 3070 "configure"
#include "confdefs.h" #include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */ /* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2 /* We use char because int might match the return type of a gcc2
@ -3074,7 +3077,7 @@ int main() {
thr_create() thr_create()
; return 0; } ; return 0; }
EOF EOF
if { (eval echo configure:3078: \"$ac_link\") 1>&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* rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes" eval "ac_cv_lib_$ac_lib_var=yes"
else else
@ -3168,7 +3171,7 @@ do
# Extract the first word of "$ac_prog", so it can be a program name with args. # Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2 set dummy $ac_prog; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 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 if eval "test \"`echo '$''{'ac_cv_path_CMAKE_AR_TMP'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else 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_LIMITS_H@%$CMAKE_HAVE_LIMITS_H%g
s%@CMAKE_HAVE_UNISTD_H@%$CMAKE_HAVE_UNISTD_H%g s%@CMAKE_HAVE_UNISTD_H@%$CMAKE_HAVE_UNISTD_H%g
s%@fullSrcDir@%$fullSrcDir%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_LINK_FLAGS@%$CMAKE_SHLIB_LINK_FLAGS%g
s%@CMAKE_SHLIB_BUILD_FLAGS@%$CMAKE_SHLIB_BUILD_FLAGS%g s%@CMAKE_SHLIB_BUILD_FLAGS@%$CMAKE_SHLIB_BUILD_FLAGS%g
s%@CMAKE_MODULE_LINK_FLAGS@%$CMAKE_MODULE_LINK_FLAGS%g s%@CMAKE_MODULE_LINK_FLAGS@%$CMAKE_MODULE_LINK_FLAGS%g

View File

@ -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. # Step 4: set configuration options based on system name and version.
CMAKE_C_LINK_SHARED=${CC}
fullSrcDir=`cd $srcdir; pwd` fullSrcDir=`cd $srcdir; pwd`
AC_SUBST(fullSrcDir) AC_SUBST(fullSrcDir)
case $system in case $system in
@ -181,18 +182,20 @@ case $system in
CMAKE_SHLIB_RUNTIME_SEP=":" CMAKE_SHLIB_RUNTIME_SEP=":"
;; ;;
HP-UX-*) HP-UX-*)
CMAKE_C_LINK_SHARED=ld
CMAKE_SHLIB_CFLAGS="+Z" CMAKE_SHLIB_CFLAGS="+Z"
CMAKE_SHLIB_LD_LIBS="" CMAKE_SHLIB_LD_LIBS=""
CMAKE_SHLIB_SUFFIX=".sl" CMAKE_SHLIB_SUFFIX=".sl"
CMAKE_MODULE_SUFFIX=".sl" CMAKE_MODULE_SUFFIX=".sl"
CMAKE_DL_LIBS="-ldld" CMAKE_DL_LIBS="-ldld"
CMAKE_SHLIB_BUILD_FLAGS='+Z -Wl,-E -b -L/usr/lib' CMAKE_SHLIB_BUILD_FLAGS='+Z -E -b -L/usr/lib'
CMAKE_SHLIB_LINK_FLAGS='-Wl,+s' CMAKE_SHLIB_LINK_FLAGS='+s'
CMAKE_MODULE_BUILD_FLAGS='+Z -Wl,-E -b -L/usr/lib' CMAKE_MODULE_BUILD_FLAGS='+Z -E -b -L/usr/lib'
CMAKE_MODULE_LINK_FLAGS='-Wl,+s' CMAKE_MODULE_LINK_FLAGS='+s'
CMAKE_SHLIB_RUNTIME_FLAG='-Wl,+b,' CMAKE_SHLIB_RUNTIME_FLAG='+b,'
CMAKE_SHLIB_RUNTIME_SEP=':' CMAKE_SHLIB_RUNTIME_SEP=':'
if test $ac_cv_prog_gcc = yes; then if test $ac_cv_prog_gcc = yes; then
CMAKE_C_LINK_SHARED=${CC}
CMAKE_SHLIB_CFLAGS="-fPIC" CMAKE_SHLIB_CFLAGS="-fPIC"
CMAKE_SHLIB_BUILD_FLAGS='-shared -Wl,-E -Wl,-b' CMAKE_SHLIB_BUILD_FLAGS='-shared -Wl,-E -Wl,-b'
CMAKE_SHLIB_LINK_FLAGS='-Wl,+s' CMAKE_SHLIB_LINK_FLAGS='-Wl,+s'
@ -479,7 +482,7 @@ if test "${SHLIB_CFLAGS}" != ""; then
fi fi
CMAKE_LD_SEARCH_FLAGS="${LD_SEARCH_FLAGS}" CMAKE_LD_SEARCH_FLAGS="${LD_SEARCH_FLAGS}"
AC_SUBST(CMAKE_C_LINK_SHARED)
AC_SUBST(CMAKE_SHLIB_LINK_FLAGS) AC_SUBST(CMAKE_SHLIB_LINK_FLAGS)
AC_SUBST(CMAKE_SHLIB_BUILD_FLAGS) AC_SUBST(CMAKE_SHLIB_BUILD_FLAGS)
AC_SUBST(CMAKE_MODULE_LINK_FLAGS) AC_SUBST(CMAKE_MODULE_LINK_FLAGS)

View File

@ -887,6 +887,31 @@ if test $ac_cv_prog_gxx = yes; then
fi 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. # generate output files.
# create mkdir files just to make some of the directories # 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_AR_TMP@%$CMAKE_AR_TMP%g
s%@CMAKE_CXX_AR@%$CMAKE_CXX_AR%g s%@CMAKE_CXX_AR@%$CMAKE_CXX_AR%g
s%@CMAKE_CXX_AR_ARGS@%$CMAKE_CXX_AR_ARGS%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 s%@CMAKE_COMPILER_IS_GNUCXX@%$CMAKE_COMPILER_IS_GNUCXX%g
CEOF CEOF

View File

@ -180,6 +180,31 @@ if test $ac_cv_prog_gxx = yes; then
CMAKE_COMPILER_IS_GNUCXX=1 CMAKE_COMPILER_IS_GNUCXX=1
fi 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) AC_SUBST(CMAKE_COMPILER_IS_GNUCXX)
# generate output files. # generate output files.
# create mkdir files just to make some of the directories # create mkdir files just to make some of the directories

View File

@ -4,7 +4,7 @@
SET_SOURCE_FILES_PROPERTIES(complex SET_SOURCE_FILES_PROPERTIES(complex
COMPILE_FLAGS "-DFILE_HAS_EXTRA_COMPILE_FLAGS") COMPILE_FLAGS "-DFILE_HAS_EXTRA_COMPILE_FLAGS")
ADD_EXECUTABLE(complex complex) ADD_EXECUTABLE(complex complex)
SET(COMPLEX_LIBS CMakeTestLibrary;CMakeTestLibraryShared) SET(COMPLEX_LIBS CMakeTestLibrary;CMakeTestLibraryShared;CMakeTestCLibraryShared)
TARGET_LINK_LIBRARIES(complex ${COMPLEX_LIBS}) TARGET_LINK_LIBRARIES(complex ${COMPLEX_LIBS})
# #

View File

@ -2,6 +2,9 @@
#include "ExtraSources/file1.h" #include "ExtraSources/file1.h"
#include "file2.h" #include "file2.h"
#include "sharedFile.h" #include "sharedFile.h"
extern "C" {
#include "testConly.h"
}
#include "cmStandardIncludes.h" #include "cmStandardIncludes.h"
#include "cmSystemTools.h" #include "cmSystemTools.h"
@ -103,6 +106,14 @@ int main()
{ {
cmPassed("Call to sharedFunction from shared library worked."); 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) if(file1() != 1)
{ {

View File

@ -26,6 +26,8 @@ ADD_LIBRARY(CMakeTestLibrary LibrarySources)
SOURCE_FILES(SharedLibrarySources sharedFile) SOURCE_FILES(SharedLibrarySources sharedFile)
ADD_LIBRARY(CMakeTestLibraryShared SHARED SharedLibrarySources) ADD_LIBRARY(CMakeTestLibraryShared SHARED SharedLibrarySources)
ADD_LIBRARY(CMakeTestCLibraryShared SHARED testConly.c)
# #
# Attach a post-build custom-command to the lib. # Attach a post-build custom-command to the lib.
# It runs ${CREATE_FILE_EXE} which will create a file. # It runs ${CREATE_FILE_EXE} which will create a file.

View File

@ -0,0 +1,6 @@
#include "sharedFile.h"
int CsharedFunction()
{
return 1;
}

View File

@ -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();

View File

@ -4,7 +4,7 @@
SET_SOURCE_FILES_PROPERTIES(complex SET_SOURCE_FILES_PROPERTIES(complex
COMPILE_FLAGS "-DFILE_HAS_EXTRA_COMPILE_FLAGS") COMPILE_FLAGS "-DFILE_HAS_EXTRA_COMPILE_FLAGS")
ADD_EXECUTABLE(complex complex) ADD_EXECUTABLE(complex complex)
SET(COMPLEX_LIBS CMakeTestLibrary;CMakeTestLibraryShared) SET(COMPLEX_LIBS CMakeTestLibrary;CMakeTestLibraryShared;CMakeTestCLibraryShared)
TARGET_LINK_LIBRARIES(complex ${COMPLEX_LIBS}) TARGET_LINK_LIBRARIES(complex ${COMPLEX_LIBS})
# #

View File

@ -2,6 +2,9 @@
#include "ExtraSources/file1.h" #include "ExtraSources/file1.h"
#include "file2.h" #include "file2.h"
#include "sharedFile.h" #include "sharedFile.h"
extern "C" {
#include "testConly.h"
}
#include "cmStandardIncludes.h" #include "cmStandardIncludes.h"
#include "cmSystemTools.h" #include "cmSystemTools.h"
@ -103,6 +106,14 @@ int main()
{ {
cmPassed("Call to sharedFunction from shared library worked."); 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) if(file1() != 1)
{ {

View File

@ -26,6 +26,8 @@ ADD_LIBRARY(CMakeTestLibrary LibrarySources)
SOURCE_FILES(SharedLibrarySources sharedFile) SOURCE_FILES(SharedLibrarySources sharedFile)
ADD_LIBRARY(CMakeTestLibraryShared SHARED SharedLibrarySources) ADD_LIBRARY(CMakeTestLibraryShared SHARED SharedLibrarySources)
ADD_LIBRARY(CMakeTestCLibraryShared SHARED testConly.c)
# #
# Attach a post-build custom-command to the lib. # Attach a post-build custom-command to the lib.
# It runs ${CREATE_FILE_EXE} which will create a file. # It runs ${CREATE_FILE_EXE} which will create a file.

View File

@ -0,0 +1,6 @@
#include "sharedFile.h"
int CsharedFunction()
{
return 1;
}

View File

@ -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();

View File

@ -4,7 +4,7 @@
SET_SOURCE_FILES_PROPERTIES(complex SET_SOURCE_FILES_PROPERTIES(complex
COMPILE_FLAGS "-DFILE_HAS_EXTRA_COMPILE_FLAGS") COMPILE_FLAGS "-DFILE_HAS_EXTRA_COMPILE_FLAGS")
ADD_EXECUTABLE(complex complex) ADD_EXECUTABLE(complex complex)
SET(COMPLEX_LIBS CMakeTestLibrary;CMakeTestLibraryShared) SET(COMPLEX_LIBS CMakeTestLibrary;CMakeTestLibraryShared;CMakeTestCLibraryShared)
TARGET_LINK_LIBRARIES(complex ${COMPLEX_LIBS}) TARGET_LINK_LIBRARIES(complex ${COMPLEX_LIBS})
# #

View File

@ -2,6 +2,9 @@
#include "ExtraSources/file1.h" #include "ExtraSources/file1.h"
#include "file2.h" #include "file2.h"
#include "sharedFile.h" #include "sharedFile.h"
extern "C" {
#include "testConly.h"
}
#include "cmStandardIncludes.h" #include "cmStandardIncludes.h"
#include "cmSystemTools.h" #include "cmSystemTools.h"
@ -103,6 +106,14 @@ int main()
{ {
cmPassed("Call to sharedFunction from shared library worked."); 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) if(file1() != 1)
{ {

View File

@ -26,6 +26,8 @@ ADD_LIBRARY(CMakeTestLibrary LibrarySources)
SOURCE_FILES(SharedLibrarySources sharedFile) SOURCE_FILES(SharedLibrarySources sharedFile)
ADD_LIBRARY(CMakeTestLibraryShared SHARED SharedLibrarySources) ADD_LIBRARY(CMakeTestLibraryShared SHARED SharedLibrarySources)
ADD_LIBRARY(CMakeTestCLibraryShared SHARED testConly.c)
# #
# Attach a post-build custom-command to the lib. # Attach a post-build custom-command to the lib.
# It runs ${CREATE_FILE_EXE} which will create a file. # It runs ${CREATE_FILE_EXE} which will create a file.

View File

@ -0,0 +1,6 @@
#include "sharedFile.h"
int CsharedFunction()
{
return 1;
}

View File

@ -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();