What about the attached patches adding and using LLVM_BUILD_STATIC?
On 4 November 2014 09:08, NAKAMURA Takumi <[email protected]> wrote:
> Rafael,
>
> I suppose LIBCLANG_BUILD_STATIC is an option to build *extra* libclang.a.
> Then I'd like to use libclang.so regardless of LIBCLANG_BUILD_STATIC.
> FYI, I am enabling LIBCLANG_BUILD_STATIC in my local build tree.
>
> I suggest options;
>
> - Change "libclang and libclang_static" <=> "libclang_shared and
> libclang" according to CMAKE_EXE_LINKER_FLAGS (to scan it).
> - Introduce another option like LLVM_BUILD_STATIC.
> With this, do you think libclang.so could be built with explicit
> target? (like "ninja libclang_shared")
>
> 2014-11-04 0:22 GMT+09:00 Rafael Espíndola <[email protected]>:
>> A build with -static currently fails when trying to link c-index-test.
>> The attached patch fixes it.
>>
>> Cheers,
>> Rafael
diff --git a/cmake/modules/HandleLLVMOptions.cmake b/cmake/modules/HandleLLVMOptions.cmake
index 3e0d9b0..0fceb3d 100644
--- a/cmake/modules/HandleLLVMOptions.cmake
+++ b/cmake/modules/HandleLLVMOptions.cmake
@@ -167,6 +167,10 @@ if( CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32 )
endif( LLVM_BUILD_32_BITS )
endif( CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32 )
+if (LLVM_BUILD_STATIC)
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
+endif()
+
if( XCODE )
# For Xcode enable several build settings that correspond to
# many warnings that are on by default in Clang but are
diff --git a/tools/c-index-test/CMakeLists.txt b/tools/c-index-test/CMakeLists.txt
index 113172a..d0872fd 100644
--- a/tools/c-index-test/CMakeLists.txt
+++ b/tools/c-index-test/CMakeLists.txt
@@ -9,9 +9,15 @@ if(NOT MSVC)
)
endif()
-target_link_libraries(c-index-test
- libclang
+if (LLVM_BUILD_STATIC)
+ target_link_libraries(c-index-test
+ libclang_static
)
+else()
+ target_link_libraries(c-index-test
+ libclang
+ )
+endif()
set_target_properties(c-index-test
PROPERTIES
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits