Closed rbraud closed 9 years ago
What do you think about compiling both versions? Like this:
add_library(${PROJECT_NAME}-static STATIC ${SRC_FILES} ${CMAKE_CURRENT_BINARY_DIR}/datadir.cpp ${INCLUDE_FILES})
target_link_libraries(${PROJECT_NAME}-static hiredis ${REDIS3M_BOOST_LIBS})
set_target_properties(${PROJECT_NAME}-static PROPERTIES OUTPUT_NAME ${PROJECT_NAME})
The only problem with that is you have to compile all of the source files twice if you don't give a specific target to make, and in most cases users won't need both versions of the library, only one of them. But it's up to you, I can just use the redis3m-static target if you'd prefer to have it that way.
Just committed, take a look. Thanks for reporting this!
Hi, I was trying to get cmake to build a .a instead of a .so but I could not seem to be able to do it. However, it seems if you change the
add_library
call in CMakeLists.txt to:add_library(${PROJECT_NAME} ${SRC_FILES} ${CMAKE_CURRENT_BINARY_DIR}/datadir.cpp ${INCLUDE_FILES})
(ie, remove SHARED), then the default behavior will still be to generate a shared library. But if you want a static library, you can run cmake -DBUILD_SHARED_LIBS:BOOL=OFF and then it will build a static library when running "make." Do you think this change is acceptable?