dev-cafe / cmake-cookbook

CMake Cookbook recipes.
Other
2.71k stars 696 forks source link

chapter-01/recipe-05/cxx-example/CMakeLists.txt - wrong logic #513

Open hanxiatu-fc opened 5 years ago

hanxiatu-fc commented 5 years ago

Expected Behavior

when USE_LIBRARY is true, we can change some varible to make shared or static lib

Current Behavior

when USE_LIBRARY is true, we can only make shared lib

Possible Solution

  1. add option

option(SHARED_LIB "Compile shared lib" ON)

  1. use USE_LIBRARY and SHARED_LIB togather to decide make shared or staic lib

cmake_dependent_option( MAKE_STATIC_LIBRARY "Compile sources into a static library" ON "USE_LIBRARY;NOT SHARED_LIB" OFF )

cmake_dependent_option( MAKE_SHARED_LIBRARY "Compile sources into a shared library" ON "USE_LIBRARY;SHARED_LIB" OFF )

Steps to Reproduce (for bugs)

any

Context

any

Your Environment

any

robertodr commented 5 years ago

Hi and thanks for your interest in this project. This bug slipped though! Thanks for reporting it and proposing a solution.