Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6346669
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:03:51+00:00 2026-05-24T21:03:51+00:00

I am currently working on a project which is using cmake. The project has

  • 0

I am currently working on a project which is using cmake. The project has alsa as an optional dependency. Thus the projects CMakeLists.txt contains.

find_package(ALSA)

However I want the build to never build against alsa, even if if is on my system. (Kind of like the --without-ALSA that would have been in a configure)

I want to do this in a commandline-parameter when running cmake, not by modifying the CMakeLists.txt

Is this possible with cmake?

EDIT:

OR would it be better to have the project implement something like this:

 if(WITH_ALSA)
    find_package(ALSA REQUIRED)
 elseif(NOT WITHOUT_ALSA)
    find_package(ALSA)
 endif()

EDIT2:

In the end I used the with & without option I described above (edit1). To have a little readability I defined a macro that acually does everything for me.
See the FindOptionalPackage.cmake in the FreeRDP project

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T21:03:52+00:00Added an answer on May 24, 2026 at 9:03 pm

    First run CMake and open the generated CMakeCache.txt file. You will find something like:

    ALSA_INCLUDE_DIR=/usr/include/alsa

    (you basically just need to know how the variable is called). Then you should be able to call cmake with a parameter

    -DALSA_INCLUDE_DIR=ALSA_INCLUDE_DIR_NOTFOUND
    

    This tells cmake, that alsa is not on your system. If this does not work, try to look at other variables containing alsa and set them to some values indicating the library could not been found. If the FindALSA.cmake script is implemented correctly (i.e. does correct caching), this should work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently working on a project which contains a window, that has a
I currently working on a project which uses Spree Cart and which has hence
I'm currently working on a project which is using EF Code First with POCOs.
I'm currently working on a project which is using EF Code First with POCOs.
I'm currently working on a simple web project, for which I am using the
I am currently working on a project which is using Apache HttpClient 4.1.2 and
Currently I am working on a project which has following setup. AVR micro-controller IDE
I am currently working on a project which requires migration of content from different
I'm currently working on a project which will support multiple file writing specifications (imagine
I'm currently working on my project which consists of front and back-end written in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.