From b9c84ab7e92730a3e6556f3af56a43dbeab681bf Mon Sep 17 00:00:00 2001 From: Vitor Santos Costa Date: Wed, 6 Sep 2017 01:17:43 +0100 Subject: [PATCH] cmake --- CMakeLists.txt | 8 ++--- CXX/CMakeLists.txt | 2 +- JIT/CMakeLists.txt | 2 +- cmake/Prelims.cmake | 58 ++++++++++++++++------------------- library/lammpi/CMakeLists.txt | 2 +- library/matlab/CMakeLists.txt | 2 +- library/matrix/CMakeLists.txt | 2 +- library/random/CMakeLists.txt | 2 +- library/regex/CMakeLists.txt | 2 +- library/rltree/CMakeLists.txt | 2 +- library/system/CMakeLists.txt | 2 +- library/tries/CMakeLists.txt | 4 +-- os/iopreds.c | 2 +- swi/library/CMakeLists.txt | 5 +-- 14 files changed, 46 insertions(+), 49 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a6adcfc9a..be051ff39 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -94,9 +94,9 @@ OPTION (WITH_SWIG " Enable SWIG interfaces to foreign languages" ON) IF (WITH_SWIG OR ANDROID) find_host_package (SWIG) - macro_log_feature (SWIG_FOUND "Swig" - "Use SWIG Interface Generator " - "http://www.swig.org" ON) + # macro_log_feature (SWIG_FOUND "Swig" + # "Use SWIG Interface Generator " + # "http://www.swig.org" ON) ENDIF (WITH_SWIG OR ANDROID) option (WITH_PYTHON @@ -124,7 +124,7 @@ ENDIF (WITH_PYTHON) -add_library( # Sets the name of the library. +add_lib( # Sets the name of the library. libYap # Sets the library as a shared library. diff --git a/CXX/CMakeLists.txt b/CXX/CMakeLists.txt index 80259bad8..b4b69d352 100644 --- a/CXX/CMakeLists.txt +++ b/CXX/CMakeLists.txt @@ -24,7 +24,7 @@ if ( WIN32) set_property( DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS "_YAP_NOT_INSTALLED_=1;HAVE_CONFIG_H=1;_GNU_SOURCE;YAP_KERNEL=1" ) else() - add_external (YAP++ ${CXX_SOURCES} ) + add_lib(YAP++ ${CXX_SOURCES} ) MY_target_link_libraries(YAP++ ${CMAKE_DL_LIBS} libYap) MY_install(TARGETS YAP++ diff --git a/JIT/CMakeLists.txt b/JIT/CMakeLists.txt index fe73e70d7..183c6cffa 100644 --- a/JIT/CMakeLists.txt +++ b/JIT/CMakeLists.txt @@ -58,7 +58,7 @@ set (POSITION_INDEPENDENT_CODE TRUE) set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} ${LLVM_CXXFLAGS}) -add_library (libyapjit SHARED +add_lib (libyapjit ${LIBJIT_SOURCES} ${LIBJIT_HEADERS} ) diff --git a/cmake/Prelims.cmake b/cmake/Prelims.cmake index 59d04c1bd..5496a46e5 100644 --- a/cmake/Prelims.cmake +++ b/cmake/Prelims.cmake @@ -7,6 +7,22 @@ if (POLICY CMP0042) cmake_policy( SET CMP0042 NEW) endif() +function(add_to_group output list) + set (result "") + foreach (path IN LISTS ${list}) + get_source_file_property(result ${path} LOCATION) + list( APPEND tmp ${result}) + endforeach () + list( APPEND ${output} ${tmp}) + set (${output} ${${output}} CACHE INTERNAL "prolog library files") +endfunction(add_to_group output list ) + +function(add_to_libgroup arg list) + set (x ${CMAKE_CURRENT_BINARY_DIR}/*${arg}*${CMAKE_SHARED_LIBRARY_SUFFIX}) + list( APPEND ${list} ${x}) + set(${list} ${${list}} CACHE INTERNAL "prolog library files") +endfunction(add_to_libgroup arg list ) + if (ANDROID_OLD) macro ( MY_add_custom_target) endmacro() @@ -16,30 +32,19 @@ else() endmacro() endif() - -if (ANDROID_OLD) - macro ( add_component arg1) - foreach(item ${ARGN}) - get_filename_component(i ${item} ABSOLUTE) - set( ALL_SOURCES ${ALL_SOURCES} ${i} ) - endforeach() - set( ALL_SOURCES ${ALL_SOURCES} PARENT_SCOPE ) - endmacro() - macro ( add_external arg1) - foreach(item ${ARGN}) - get_filename_component(i ${item} ABSOLUTE) - set( ALL_SOURCES ${ALL_SOURCES} ${i} ) - endforeach() - set( ALL_SOURCES ${ALL_SOURCES} PARENT_SCOPE ) - endmacro() +if (WIN32) + macro ( add_component arg1 ) + add_library ( ${arg1} OBJECT ${ARGN}) + endmacro() else() - macro ( add_component arg1 ) - add_library ( ${arg1} OBJECT ${ARGN}) - endmacro() - macro ( add_external arg1 ) - add_library ( ${arg1} SHARED ${ARGN}) - endmacro() + macro ( add_component arg1 ) + add_library ( ${arg1} OBJECT ${ARGN}) + endmacro() endif() +macro ( add_lib arg1 ) + add_library ( ${arg1} SHARED ${ARGN}) + add_to_libgroup( ${arg1} YAP_DLLS ) +endmacro() if (ANDROID_OLD) macro ( MY_add_dependencies) @@ -168,12 +173,3 @@ set (pl_library "" CACHE INTERNAL "prolog library files" ) set (pl_os_library "" CACHE INTERNAL "prolog os files" ) set (pl_boot_library "" CACHE INTERNAL "prolog boot files" ) -function(add_to_group output list) - set (result "") - foreach (path IN LISTS ${list}) - get_source_file_property(result ${path} LOCATION) - list( APPEND tmp ${result}) - endforeach () - list( APPEND ${output} ${tmp}) - set (${output} ${${output}} CACHE INTERNAL "prolog library files") -endfunction(add_to_group output list ) diff --git a/library/lammpi/CMakeLists.txt b/library/lammpi/CMakeLists.txt index 1ffa90d44..4e8b48e81 100644 --- a/library/lammpi/CMakeLists.txt +++ b/library/lammpi/CMakeLists.txt @@ -67,7 +67,7 @@ if (MPI_C_FOUND) # pass to the MPI program. # - add_library (yap_mpi SHARED ${MPI_SOURCES}) + add_lib (yap_mpi ${MPI_SOURCES}) target_link_libraries(yap_mpi libYap ${MPI_C_LIBRARIES}) diff --git a/library/matlab/CMakeLists.txt b/library/matlab/CMakeLists.txt index 4cda21568..71bb38db0 100644 --- a/library/matlab/CMakeLists.txt +++ b/library/matlab/CMakeLists.txt @@ -7,7 +7,7 @@ if (MATLAB_FOUND) # MATLAB_MX_LIBRARY: path to libmx.lib # MATLAB_ENG_LIBRARY: path to libeng.lib - add_library (matlab SHARED matlab.c) + add_li (matlab matlab.c) set_target_properties (matlab PROPERTIES prefix "") diff --git a/library/matrix/CMakeLists.txt b/library/matrix/CMakeLists.txt index b8a62a5c2..98ce8bad8 100644 --- a/library/matrix/CMakeLists.txt +++ b/library/matrix/CMakeLists.txt @@ -1,5 +1,5 @@ -add_library (matrix SHARED matrix.c) +add_lib(matrix matrix.c) target_link_libraries(matrix libYap) diff --git a/library/random/CMakeLists.txt b/library/random/CMakeLists.txt index 44c7a38ed..5c633500c 100644 --- a/library/random/CMakeLists.txt +++ b/library/random/CMakeLists.txt @@ -1,6 +1,6 @@ set( LIBRANDOM_SOURCES yap_random.c) -add_external (yap_random ${LIBRANDOM_SOURCES}) +add_lib(yap_random ${LIBRANDOM_SOURCES}) if (ANDROID) else() diff --git a/library/regex/CMakeLists.txt b/library/regex/CMakeLists.txt index 23147bc35..7fdb341cf 100644 --- a/library/regex/CMakeLists.txt +++ b/library/regex/CMakeLists.txt @@ -17,7 +17,7 @@ set ( REGEX_SOURCES -add_library (regexp SHARED regexp.c ${REGEX_SOURCES}) +add_lib(regexp regexp.c ${REGEX_SOURCES}) target_link_libraries(regexp libYap) diff --git a/library/rltree/CMakeLists.txt b/library/rltree/CMakeLists.txt index 0fd6553ac..b8e58bb6f 100644 --- a/library/rltree/CMakeLists.txt +++ b/library/rltree/CMakeLists.txt @@ -4,7 +4,7 @@ set ( RLTREE_SOURCES range_list.h ) -add_library (yap_rl SHARED yap_rl.c ${RLTREE_SOURCES}) +add_lib(yap_rl yap_rl.c ${RLTREE_SOURCES}) target_link_libraries(yap_rl libYap) diff --git a/library/system/CMakeLists.txt b/library/system/CMakeLists.txt index 22df2bb74..5e8662b97 100644 --- a/library/system/CMakeLists.txt +++ b/library/system/CMakeLists.txt @@ -2,7 +2,7 @@ set( LIBSYSTEM_SOURCES sys.c crypto/md5.c ) set( LIBSYSTEM_HEADERS crypto/md5.h) -add_external (sys ${LIBSYSTEM_SOURCES}) +add_lib(sys ${LIBSYSTEM_SOURCES}) if (ANDROID) set (TARGET libYap) else() diff --git a/library/tries/CMakeLists.txt b/library/tries/CMakeLists.txt index 62dec0f91..b4371af99 100644 --- a/library/tries/CMakeLists.txt +++ b/library/tries/CMakeLists.txt @@ -6,7 +6,7 @@ set ( TRIES_SOURCES tries.c ) -add_library (tries SHARED ${TRIES_SOURCES}) +add_lib(tries ${TRIES_SOURCES}) target_link_libraries(tries libYap) @@ -27,7 +27,7 @@ set ( ITRIES_SOURCES if (ANDROID OR WIN32) add_component ( otries ${TRIES_SOURCES} ) endif() -add_library (itries SHARED ${ITRIES_SOURCES}) +add_lib(itries ${ITRIES_SOURCES}) target_link_libraries(itries libYap) diff --git a/os/iopreds.c b/os/iopreds.c index 167959c8e..0162e66fb 100644 --- a/os/iopreds.c +++ b/os/iopreds.c @@ -337,7 +337,7 @@ static void InitStdStream(int sno, SMALLUNSGN flags, FILE *file, VFS_t *vfsp) { #endif /* HAVE_SETBUF */ } -void Yap_InitStdStream(int sno, SMALLUNSGN flags, FILE *file, VFS_t *vfsp) { +void Yap_InitStdStream(int sno, unsigned int flags, FILE *file, VFS_t *vfsp) { InitStdStream(sno, flags, file, vfsp); } diff --git a/swi/library/CMakeLists.txt b/swi/library/CMakeLists.txt index 43c5d24f3..8f75d89bd 100644 --- a/swi/library/CMakeLists.txt +++ b/swi/library/CMakeLists.txt @@ -36,12 +36,13 @@ set (LIBRARY_PL dcg/basics.pl ) -add_to_group( pl_library LIBRARY_PL ) if (ANDROID) file(INSTALL ${LIBRARY_PL} DESTINATION ${libpl}) - else() + endif() +install(FILES ${LIBRARY_PL} DESTINATION ${libpl} ) + add_to_group( pl_swi_library LIBRARY_PL )