Here is the project tree : It's a static library that uses another static library
Static_lib/
|
----src/
|----src1.cpp
|----src2.cpp
----inc/
|----head1.h
|----head2.h
----Static_lib2/
|----lib/
|----32/
|Debug/
lib2.lib
|Release/
lib2.lib
|----64/
|Debug/
lib2.lib
|Release/
lib2.lib
|----include/
|bunch of headers
----build/
----CMakeLists.txt
Here is my CMakeLists.txt :
cmake_minimum_required(VERSION 3.5.1)
project(Static_lib)
set(SOURCE_FILES src/src1.cpp src/src2.cpp)
set(HEADER_FILES inc/head1.h inc/head2.h)
add_library(Static_lib STATIC ${SOURCE_FILES} ${HEADER_FILES})
target_include_directories(Static_lib PUBLIC
${CMAKE_SOURCE_DIR}/inc
${CMAKE_SOURCE_DIR}/Static_lib2/include
)
if(CMAKE_SYSTEM_NAME STREQUAL Linux)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB32_PATHS FALSE)
else(CMAKE_SIZEOF_VOID_P EQUAL 8)
set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB32_PATHS TRUE)
endif(CMAKE_SIZEOF_VOID_P EQUAL 8)
find_library(STATIC_LIB2 libcrypto.a)
target_link_libraries(Static_lib "${STATIC_LIB2}")
elseif(CMAKE_SYSTEM_NAME STREQUAL Windows)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
target_link_libraries(Static_lib debug ${CMAKE_SOURCE_DIR}/Static_lib2/lib/64/Debug/lib2.lib)
target_link_libraries(Static_lib optimized ${CMAKE_SOURCE_DIR}/Static_lib2/lib/64/Release/lib2.lib)
else(CMAKE_SIZEOF_VOID_P EQUAL 8)
target_link_libraries(Static_lib debug ${CMAKE_SOURCE_DIR}/Static_lib2/lib/32/Debug/lib2.lib)
target_link_libraries(Static_lib optimized ${CMAKE_SOURCE_DIR}/Static_lib2/lib/32/Release/lib2.lib)
endif(CMAKE_SIZEOF_VOID_P EQUAL 8)
endif(CMAKE_SYSTEM_NAME STREQUAL Linux)
When I create the project using Visual studio generator, the project is created with no error or warning, however there are no dependencies and no libraries in the project properties.
After building, I get a library that doesn't actually have the size it is supposed to have.
Can someone give some insight? Maybe my CMakeLists code is wrong?
Thanks in advance!