# What is the recommanded directory and install structure for a root lib?

**URL:** <https://root-forum.cern.ch/t/what-is-the-recommanded-directory-and-install-structure-for-a-root-lib/54485>\
**Category:** Newbie\
**Created:** [April 14, 2023, 2:39pm UTC](https://root-forum.cern.ch/t/what-is-the-recommanded-directory-and-install-structure-for-a-root-lib/54485 "2023-04-14T14:39:34Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [April 17, 2023, 7:05am UTC](https://root-forum.cern.ch/t/what-is-the-recommanded-directory-and-install-structure-for-a-root-lib/54485/2 "2023-04-17T07:05:01Z")

</div>

Welcome to the ROOT Forum!  
The directory structure of the project is not really related to the install directory (set by `CMAKE_INSTALL_PREFIX`). in general, I use a directory for the project (`project_name`) with a `source` and a `build` directory. And here is an example of `CMakeLists.txt`:

```auto
# Check if cmake has the required version
CMAKE_MINIMUM_REQUIRED(VERSION 3.16.4 FATAL_ERROR)

set(PROJECT_NAME MyProject)
project(${PROJECT_NAME})

find_package(ROOT REQUIRED)

set(CMAKE_CXX_FLAGS "${ROOT_CXX_FLAGS}" )

include(${ROOT_USE_FILE})
include_directories(${ROOT_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
link_directories(${ROOT_LIBRARY_DIR})

set(HEADERS
  header1.h
  header2.h
  header3.h
)

set(SOURCES
  source1.cxx
  source2.cxx
  source3.cxx
)

ROOT_GENERATE_DICTIONARY(${PROJECT_NAME}Dict.cxx ${HEADERS} LINKDEF LinkDef.h)

add_library(lib${PROJECT_NAME} SHARED ${SOURCES} ${PROJECT_NAME}Dict.cxx)
target_link_libraries(lib${PROJECT_NAME} ${ROOT_LIBRARIES})
if(MSVC)
  set_target_properties(lib${PROJECT_NAME} PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
endif()
install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION ${PROJECT_NAME} COMPONENT applications)
install(DIRECTORY data/ DESTINATION ${PROJECT_NAME}/data COMPONENT data)
install(DIRECTORY icons/ DESTINATION ${PROJECT_NAME}/icons COMPONENT icons)

```

See also [How to use CMake to compile with ROOT libraries - #2 by bellenot](https://root-forum.cern.ch/t/how-to-use-cmake-to-compile-with-root-libraries/54458/2)

---

_[View the full topic](https://root-forum.cern.ch/t/what-is-the-recommanded-directory-and-install-structure-for-a-root-lib/54485)._
