Reputation: 21
I recently use clion to build my project, I can use cmake to build all of my project, but use clion build all failed. Can anyone help me? Thanks.
I use clion version is 2017.2,use clion bundled cmake 3.8.2 and gdb 3.5.1. my project structure:
project
├── project1
│ ├── src
│ └── CMakeLists.txt
├── project2
│ ├── src
│ └── CMakeLists.txt
├── project3
│ ├── src
│ └── CMakeLists.txt
└──CMakeLists.txt
project's CMakeLists.txt is:
add_subdirectory(./project1)
add_subdirectory(./project2)
add_subdirectory(./project3)
project1's CMakeLists.txt use to build static lib1.a:
aux_source_directory(./src ${LIB1_SRC})
include_directories(./src ${LIB1_INC})
add_library(lib1 STATIC ${LIB1_SRC})
project2's CMakeLists.txt use to build static lib2.a:
aux_source_directory(./src ${LIB2_SRC})
include_directories(./src ${LIB2_INC})
add_library(lib2 STATIC ${LIB2_SRC})
project3's CMakeLists.txt need to link lib1.a and lib2.a to build a share lib3.so:
aux_source_directory(./src ${LIB3_SRC})
include_directories(./src ${LIB3_INC})
add_library(lib3 SHARED ${LIB3_SRC})
target_link_libraries(lib3 ${LIB1_PATH}/lib1.a ${LIB2_PATH}/lib2.a)
set_property(TARGET lib3 PROPERTY LINK_DEPENDS ${LIB1_PATH}/lib1.a ${LIB2_PATH}/lib2.a)
when I use clion run/debug configuration to choose lib3 and buld, it will build failed, says lib1, or sometimes lib2 needed by lib3.so. I can use clion to build lib1 and lib2 sucess when choose lib1 and lib2 in run/debug configuration
I have an another try, I use cmake ./ , then make -j 16, it has the same problem. if I use make -j 1 ,it build sucess.
Why it can't parallel build? Does clion default use parallel build?
Best Regards,
Simon
Upvotes: 1
Views: 2916
Reputation: 4576
Your CMakeLists.txt are not complete but i guess changing the target_link_libraries for lib3 like this should fix your issue
target_link_libraries(lib3 lib1 lib2)
Regarding your CLion question, File->Settings->Build,Execute,Deployment->cmake->Build options
here you can configure if you want to use parallel build
Upvotes: 0