Skip to content

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

Open
@hanxiatu-fc

Description

@hanxiatu-fc

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions