ccmakebuild

CMake - Creating a static library


My project Test4 contains two files named:

  1. Structure.h
  2. Structure.c

I am using this project to create a static library that can be used by other software projects.

You can see how my CMake file is configured below:
cmake_minimum_required(VERSION 3.6)
project(Test4)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

set(SOURCE_FILES Structure.c Structure.h)
add_library(Test4 STATIC ${SOURCE_FILES})

When I build the Test4 project using the CMake configuration file above, no static library is generated. It seems as if nothing happens. Does anyone know what I am doing wrong?

Additionally:

My IDE is JetBrains CLion.


Solution

  • I had same issue. What I missed is the location where build files are created.

    CLion makes libraries or exectables under cmake-build-* directory. IfBuild, Execution, Deployment > CMake > Configuration is Debug, the lib file (.a) is created under cmake-build-debug.